docker-compose up seems to get the wrong image... ?
I am doing something pretty simple. I have a docker-compose.yml file:
tsdb:
build:
context: ./tsdb_prod
....
and in the Dockerfile in that directory I have:
FROM influxdb:0.13
COPY file_prod /etc/file_prod
and I have the file_prod file in that directory.
running docker-compose build with --no-cache to rebuild my image after changes:
0s 👍 $> docker-compose build --no-cache
[snip]
Building tsdb
Step 1 : FROM influxdb:0.13
---> c7a58aa7ce3b
Step 2 : COPY file_prod /etc/file_prod
---> ff2aa86452fd
Removing intermediate container 91c3eafd328c
Successfully built ff2aa86452fd
2s 👍 $> docker run --rm -it ff2aa86452fd /bin/bash
root@0e660d6a1784:/# ls /etc/file_prod
/etc/file_prod
But when I do my docker-compose up I see
2s 👍 $> docker-compose up
Recreating task_tsdb_1
[snip]
tsdb_1 | run: open server: open service: open "/etc/file_prod": no such file or directory
I'm pretty new to Docker. I'm sure I'm missing something stupid here. Is it building one image but starting another? I do see
2s 👍 $> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f742363da3aa 58fcf34dd924 "/entrypoint.sh influ" 44 minutes ago Exited (1) 34 minutes ago task_tsdb_1
[snip]
Not sure what's going on with that. I would appreciate anyone's insight.
OK. I found something last night that seemed to explain and fix this, and now I have the same problem again this morning. Grr.
more of my docker-compose.yml:
version: '2'
services:
tsdata:
build:
context: ./tsdb_prod
volumes:
- /var/lib/influxdb
command: "true"
tsdb:
build:
context: ./tsdb_prod
restart: always
environment:
[snip]
volumes_from:
- tsdata
ports:
[snip]
My docker-compose build output:
3s 👍 $> docker-compose build --no-cache
Building tsdata
Step 1 : FROM influxdb:0.13
---> c7a58aa7ce3b
Step 2 : COPY forelight_data.pem /etc/file_prod
---> 22d88415e029
Removing intermediate container 115d46c1e419
Successfully built 22d88415e029
Building tsdb
Step 1 : FROM influxdb:0.13
---> c7a58aa7ce3b
Step 2 : COPY forelight_data.pem /etc/file_prod
---> 78a43a107f4e
Removing intermediate container fa2aba9694e4
Successfully built 78a43a107f4e
35s 👍 $> docker run --rm -it 78a43a107f4e /bin/bash
root@ea6546277008:/# ls /etc/file_prod
/etc/file_prod
My docker-compose up output:
1s 👍 $> docker-compose up
Creating task_tsdata_1
Creating task_tsdb_1
Attaching to task_tsdata_1, task_tsdb_1
[snip]
tsdb_1 | run: open server: open service: open "/etc/file_prod": no such file or directory
same dockerfile as above.
so the file is there in the image, but the container docker-compose produces doesn't have it... ?
Can you try running docker-compose down -v --rmi then run build / up again?
I can and I will, after I deal with a couple other things. Though that sounds like it will destroy my data volume. Which is fine... now. Any solution that will involve that is pretty much out after this week, though.
Does compose get wedged this way often? If that's the case I'm inclined to go with a host directory instead of a data volume.
On Wed, May 18, 2016 at 4:35 PM Joffrey F [email protected] wrote:
Can you try running docker-compose down -v --rmi then run build / up again?
— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub https://github.com/docker/compose/issues/3472#issuecomment-220165334
No - sorry about the misunderstanding. I'm not proposing it as a solution per se, just as a debug step.
On somewhat related note, your config could potentially be made quite simpler by using named volumes instead of the volumes_from trickery you're currently using. And it would allow you to manage volumes independently of containers, too.
HTH
Nope. Same message.
I went back and deleted all my images except my copy of the base influxdb image. Then I did docker-compose build and up and got the same message. I list my images now and get
4s 👍 $> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
task_tsdata latest 2fba08d97ba7 24 seconds ago 234.7 MB
task_tsdb latest 2fba08d97ba7 24 seconds ago 234.7 MB
influxdb 0.13 c7a58aa7ce3b 7 days ago 234.7 MB
so it's finding my dockerfile from the context, finding the InfluxDB image, but not copying the file... ?
Looking at the named volumes doc... the volumes_from 'trickery' is suggested by a lot of sources. Not that I'm attached to it (this week, anyway). Having an explicit way to declare a volume does look cleaner.
Though I will say, the 'external' parameter is confusing. If they mean it mounts on the Docker host, then where? It looks like it puts it in the same place specified in the referring service. But then if there are multiple services referring to the same volume trying to locate it in different places does it error out? That seems inconsistent with Docker's design in general. I suspect I'm misunderstanding something.
ok closer...
0s 💩 $> docker-compose build
Building tsdata
Step 1 : FROM influxdb:0.13
---> c7a58aa7ce3b
Step 2 : COPY file_prod /etc/file_prod
---> Using cache
---> 0914f84be4a1
Successfully built 0914f84be4a1
Building tsdb
Step 1 : FROM influxdb:0.13
---> c7a58aa7ce3b
Step 2 : COPY file_prod /etc/file_prod
---> Using cache
---> 0914f84be4a1
Successfully built 0914f84be4a1
0s 👍 $> docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
task_tsdata latest 0914f84be4a1 About a minute ago 234.7 MB
task_tsdb latest 0914f84be4a1 About a minute ago 234.7 MB
influxdb 0.13 c7a58aa7ce3b 7 days ago 234.7 MB
so it's copying the file (and I can make it bomb if I introduce a misspelling in the filename in my dockerfile).
But the file isn't showing up in my container.
And also I don't see a clear way to answer the question: 'what image is container x based on?'
aha, inspect. No surprises... but no explanations either.
0s 👍 $> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
01bf4a397710 task_tsdb "/entrypoint.sh influ" 52 minutes ago Restarting (1) 25 minutes ago 8083/tcp, 8086/tcp task_tsdb_run_3
0s 👍 $> docker inspect 01bf4a397710 | grep Image
"Image": "sha256:0914f84be4a19ba5ad25f7404ede741c06afe63ddb06374d855df438c33a925a",
0s 👍 $> docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
task_tsdata latest 0914f84be4a1 About an hour ago 234.7 MB
task_tsdb latest 0914f84be4a1 About an hour ago 234.7 MB
influxdb 0.13 c7a58aa7ce3b 7 days ago 234.7 MB
and when I
0s 👍 $> docker run --rm -it 0914f84be4a1 /bin/bash
root@6e93d6b39419:/# ls /etc/file_prod
/etc/file_prod
root@6e93d6b39419:/# exit
and then I do docker-compose up and see the same message.
That's weird. I'll take a closer look and update when I have more info.
Looking at the named volumes doc... the volumes_from 'trickery' is suggested by a lot of sources. Not that I'm attached to it (this week, anyway). Having an explicit way to declare a volume does look cleaner.
Yeah, named volumes didn't exist and volume management through the API is a pretty recent feature, so that was indeed the conventional solution for a long time.
Though I will say, the 'external' parameter is confusing.
In that context, external just means it's not managed by Compose (i.e. it will not attempt to create or destroy it at any point, and its name will not be namespaced).
actually, that's kind of ideal. I can create a volume with docker volume and use that, and then when I get compose working I can just use external. Nice.
More messing around:
I started messing with docker volume, and found I had a huge list of volumes I had created in the course of my messing around. So I l deleted all of those, and cleaned out all my containers and images, except the base one I got from Docker Hub, redid build and up, and... got the same result.
Then I switched to your recommended volume configuration, and upgraded my Docker client from 1.10 to 1.11.1, and cleaned everything out again, containers, images, volumes, and... got the same result.
Then I deleted everything including my base image and started again and... got the same result.
So I am out of bullets. I'm going back to my direct docker invocations (which work) for now and using those. If you want I can send you my dockerfile directly--I'd rather not post it here. See if you can reproduce it.
Sure, you can send it to [redacted]. I've tried to create a simple reproduction case but everything worked fine.
I'm having the same problem here.
Further, if I docker run image, the file is there. If I docker-compose up, the file is not there.
Exact same behavior on the latest beta on OSX and on Windows.
PS C:\Users\pedro> docker-compose version
docker-compose version 1.7.1, build 0a9ab35
docker-py version: 1.8.1
CPython version: 2.7.11
OpenSSL version: OpenSSL 1.0.2d 9 Jul 2015
@pedrovanzella InfluxDB as well?
Nope, it's a rails app. Base image is rails:latest.
@shin- found it, in my case. In his words from an offline email
The quotes around the path weren't being parsed out, and as such influxdb was trying to access
"/etc/..., which, unsurprisingly, isn't a directory.
I had a bunch of fields quoted that didn't want to be quoted in docker-compose.yml. That was the one that was bombing for me, but there were others.
Anything to add, @shin- ?
@pedrovanzella Make sure the paths are correct - that also means checking for quotes that aren't parsed out, like John pointed out. If it's a different issue, please create a new ticket with more details so we can look into it.
I'm going to close this as the original issue has been solved.
Weird thing is, if I run the app with docker run, it's fine. If I run it with docker-compose up, it's not. It's almost as if docker-compose were picking the wrong image to spin the container from - an intermediary image, maybe?
that also means checking for quotes that aren't parsed out
In the Dockerfile or in docker-compose.yml? There's nothing quoted there.
I also tested on a simpler app, by copying first the Gemfile and then the rest of the app. On Windows, running with docker-compose, the image fails to run because Rails can't find the Gemfile. Running with docker run it runs fine. On OSX, it runs fine either way.
I think you need to post something that we could look at to help diagnose the problem. Describing it isn't enough. (maybe anonymize some stuff for security's sake).
On Wed, May 25, 2016 at 9:16 AM Pedro Vanzella [email protected] wrote:
that also means checking for quotes that aren't parsed out
In the Dockerfile or in docker-compose.yml? There's nothing quoted there.
I also tested on a simpler app, by copying first the Gemfile and then the rest of the app. On Windows, running with docker-compose, the image fails to run because Rails can't find the Gemfile. Running with docker run it runs fine. On OSX, it runs fine either way.
— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub https://github.com/docker/compose/issues/3472#issuecomment-221589627