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:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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