Hi,
Is there a way to manually recreate containers (without running up
)?
I find that I often run into the following situation:
$ docker-compose up
# Oh no there are errors in one of my containers, I want to rebuild it.
^C # shut down everything
$ # Change Dockerfile
$ docker-compose build
$ docker-compose up
I believe this is the recommended way of using compose, and I think it's a good interface for normal development, but I think that when I'm settings up my Dockerfile and the docker-compose.yml, I would much rather this sort of interface:
$ docker-compose start
# Oh no there are in my web container, I need to rebuild it.
$ docker-compose stop web # leaves the other non-dependent services running
$ # fix the web container Dockerfile
$ docker-compose build web
$ docker-compose start web
This doesn't work though, because the containers haven't been recreated. This has bitten me and my colleagues several times, but running docker-compose up
just to have one of the containers recreated, is quite slow.
Thanks,
I do something like this:
docker-compose build
docker-compose up -d # runs containers, but returns immediately
# Oops, something needs to be changed
docker-compose stop web
# Make changes
docker-compose build web
docker-compose up -d --no-recreate web
related to #741
I kind of think we should remove start
. It's not really useful, and it's just an alias for docker start
@dnephin, doesn't the second call to up
stop all of the running containers and then restart them?
This will recreate just web:
$ docker-compose stop web
$ docker-compose build web
$ docker-compose up -d --no-deps web
Thanks @aanand!
I am not sure why you're using the --no-recreate
flag. When I want to make changes to web
I definitely want to re-create the image, otherwise I end up running the same image.
I use:
docker-compose build
docker-compose up -d # runs containers, but returns immediately
# Oops, something needs to be changed
docker-compose stop web
# Make changes
docker-compose build web
docker-compose up -d web
Just confirming @paulhauner's comment, --no-recreate
restarted my old image with no changes.
Most helpful comment
This will recreate just web: