Rebuilding single services in docker-compose

Note to self: a single service (“container”) out of a docker-compose.yaml file is rebuilt and restarted like this:

docker-compose create container_name

 

While this complains about deprecations, there is another way. Let’s say we want to re-create a container called “web” belonging to a composition:

# stop container

docker-compose stop web

# optionally destroy container. Make sure to mount volumes you care about!
# docker-compose rm web
# Make changes, eg. vi docker-compose.yml
# Then either:

docker-compose create web
docker-compose start web

# or

docker-compose up -d --no-recreate web

As Daniel Nephin writes here: https://github.com/docker/compose/issues/1195#issuecomment-86670031

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.