Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose up assumes --no-build #1679

Closed
pcfreak30 opened this issue Jul 10, 2015 · 12 comments
Closed

docker-compose up assumes --no-build #1679

pcfreak30 opened this issue Jul 10, 2015 · 12 comments
Assignees
Labels
Milestone

Comments

@pcfreak30
Copy link

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

@dnephin
Copy link

dnephin commented Jul 10, 2015

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?

@pcfreak30
Copy link
Author

I can't seem to replicate it now which is odd. Will update if it repeats.

@bfritscher
Copy link

I had the same problem with

django:
build: .

changing it to

web:
build: .

makes it work

@pcfreak30
Copy link
Author

Don't see what would be wrong with the 1st one.

@bfritscher
Copy link

I also had the error if I manually delete a container which is part of the docker-compose set with the docker command.

@thewilli
Copy link

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

@thewilli
Copy link

@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.

@aanand
Copy link

aanand commented Aug 17, 2015

@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.

@JonathonReinhart
Copy link

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.

@dnephin
Copy link

dnephin commented Oct 26, 2015

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

@JonathonReinhart
Copy link

@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.

@sjfloat
Copy link

sjfloat commented Nov 14, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants