It seems if I try to run docker-compose up with a yml that uses build: . and the image does not already exist, it acts like --no-build is passed.
This is on version 1.3.1
up should build if the image doesn't already exist (but not if it exists). Could you provide a log sample of the output and error you're seeing?
I can't seem to replicate it now which is odd. Will update if it repeats.
I had the same problem with
django:
build: .
changing it to
web:
build: .
makes it work
Don't see what would be wrong with the 1st one.
I also had the error if I manually delete a container which is part of the docker-compose set with the docker command.
This is how I am able to reproduce it every time. docker-compose up does not rebuild a container, if the _Dockerfile_ has changed:
$ mkdir mycont
$ echo "FROM busybox" > mycont/Dockerfile
$ echo -e "mycont:\n build: mycont/" > docker-compose.yml
Building mycont...
# output, press ctrl + c to stop container
$ echo "ENV foo bar" >> mycont/Dockerfile
$ docker-compose up
Recreating test_mycont_1...
the container _mycont_ is not rebuild, even though the Dockerfile has changed.
I've installed docker-compose using pip. Version information:
$ docker-compose -v │ 38 RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
docker-compose version: 1.3.3 │ 39
CPython version: 2.7.6 │ 40 # Create user
OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
@dnephin I re-read your comment above:
up should build if the image doesn't already exist (but not if it exists)
So if my image exists (because I ran docker-compose build before), but the referred Dockefile changes, up won't trigger an automatic rebuild? It may be a misunderstanding, but I thought that up always rebuilds the image if the Dockerfile is out of sync with the image, unless --no-build is passed.
@thewilli up only checks that the image exists, not that it's up-to-date. There's actually no way to check that.
We've discussed alternative approaches, including always building and never building.
I'm seeing the same behavior as reported by the OP.
$ docker-compose version
docker-compose version: 1.4.2
docker-py version: 1.3.1
CPython version: 2.7.9
OpenSSL versionL OpenSSL 1.0.1e 11 Feb 2013
I just added a new service to a docker-compose.yml file, which has build: path/. When I run docker-compose up, I get the following message:
Service 'web' needs to be built, but --no-build was passed.
I didn't pass --no-build.
This behavior is unexpected, as docker-compose up --help says:
Builds, (re)creates, starts, and attaches to containers for a service.
I just hit this myself as well when I went and changed a service from image to build. The workaround for now is to docker rm <container name> where the container name is the compose form of <projectname>_<servicename>_1
@dnephin Actually, I was mistaken. I did the same thing as you - I changed an existing service from image to build. Thanks for the workaround.
Thanks very much for the fix!
But is there a workaround for this? I'd upgrade compose, but I'm currently stuck using an older version due to #17804
Most helpful comment
@dnephin I re-read your comment above:
So if my image exists (because I ran
docker-compose buildbefore), but the referred Dockefile changes,upwon't trigger an automatic rebuild? It may be a misunderstanding, but I thought thatupalways rebuilds the image if the Dockerfile is out of sync with the image, unless--no-buildis passed.