compose: docker-compose terminates if build directory is missing
Summary:
docker-compose
seems to pre-check that all build directories exists before running any commands. Even for commands where the build directory is not needed, like docker-compose ps
or docker-compose run ...
Command:
docker-compose ps
Result:
ERROR: build path /omnicoder either does not exist, is not accessible, or is not a valid URL.
Expected result:
Name Command State Ports
---------------------------------------------------------------------------------------------
api-server_1 npm start Up 3000/tcp
cron_1 /usr/sbin/crond -f -d 8 -c ... Up
disbatcher_1 /usr/bin/tini -- python -m ... Up
mongodb_1 /entrypoint.sh mongod Up 27017/tcp
nginx_1 nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 80/tcp
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 25
- Comments: 26
Commits related to this issue
- Fixes https://github.com/docker/compose/issues/4047 — committed to hholst80/compose-old by hholst80 8 years ago
- Fixes https://github.com/docker/compose/issues/4047 — committed to hholst80/compose-old by hholst80 8 years ago
- Fixes https://github.com/docker/compose/issues/4047 Signed-off-by: Henrik Holst <holst@matmech.com> — committed to hholst80/compose-old by hholst80 8 years ago
- add ref to compose Issue — committed to collinbarrett/FilterLists by collinbarrett 5 years ago
- fix(build): 🐛🔨 extract separate build docker-compose https://github.com/docker/compose/issues/4047 — committed to collinbarrett/FilterLists by collinbarrett 4 years ago
- fix(build): 🐛🔨 extract separate build docker-compose https://github.com/docker/compose/issues/4047 — committed to collinbarrett/FilterLists by collinbarrett 4 years ago
The best approach is to split files and provide
docker-compose
with multiple-f
stanzas, for example maybe the bare necessities to run a service can remain in thedocker-compose.yml
file, but you can add in thebuild:
part (the yaml structs will be merged) only during build operations by using e.g.docker-compose -f docker-compose.yml -f build.docker-compose.yml build
for your project.Taking this into account - terminating on missing build dir (which could potentially result in mis-built images, which would be more difficult to track downstream) could be considered a feature rather than a bug.
Version 1.24 problem still here!
v1.25.4 still no progress
I don’t think that your example is the situation that the original poster was reporting.
Impractical example:
If you are using docker-compose in 99% of cases to set up an environment with app1 and app2, then it is very nice to be able to specify that entire environment in one docker-compose file. I would be very unhappy if in my build setup I had to pass 5
-f
stanzas every time I want to test something, in that case I would end up writing a layer of tooling around docker-compose, which is what I am trying to avoid. So for now, I’m also using the trick of just creating the build directories.Note that the check for having a build directory is a strange one to do at this point, because there is absolutely no guarantee that you can build an image out of it. In particular, the check that there is a
Dockerfile
is done only when a build is requested.I think what the original poster and the people who were chiming in before are asking, is that the check for the existence of the build directory is done at the same place as the check for the existence of a
Dockerfile
. This would be more consistent, and allows people to keep usingdocker-compose
in the lightweight fashion they were used to.I’m currently running into this issue with Jenkins deployment. I use the
docker-compos build
command to build the images locally, then push them to the registry. From there I go to the production server and want todockere-compose rm -sf && docker-compose up
copying over only the compose file and I get this error.I’m getting around the issue by simply creating an empty directory. but it’s a rather clunky work around.
The build directory check happens when I run
docker-compose down
. Why do we need to check the build context before down the containers?I’m running into this same issue.
I can confirm this issue is present in docker-compose version 1.23.2, build 1110ad0.
Docker compose is very useful for non-developers to quickly get an env up and running (eg. to demo) but this issue means you have to distribute a few files and not just a docker-compose.yml. It would be a very useful fix.