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

Question: Is it possible to recreate containers manually? #1195

Closed
rockymeza opened this issue Mar 26, 2015 · 6 comments
Closed

Question: Is it possible to recreate containers manually? #1195

rockymeza opened this issue Mar 26, 2015 · 6 comments

Comments

@rockymeza
Copy link

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,

@dnephin
Copy link

dnephin commented Mar 26, 2015

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

@rockymeza
Copy link
Author

@dnephin, doesn't the second call to up stop all of the running containers and then restart them?

@aanand
Copy link

aanand commented Mar 26, 2015

This will recreate just web:

$ docker-compose stop web
$ docker-compose build web
$ docker-compose up -d --no-deps web

@rockymeza
Copy link
Author

Thanks @aanand!

@paulhauner
Copy link

paulhauner commented Nov 17, 2017

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

@mrclay
Copy link

mrclay commented Jan 11, 2019

Just confirming @paulhauner's comment, --no-recreate restarted my old image with no changes.

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

No branches or pull requests

5 participants