Docker Compose: (re)Start|Stop|Build – Single Service

By default, the docker-compose (up|stop|restart|build) commands will start, stop, restart or build all of the services (containers) listed in a docker-compose.yml file.

But there is also a way to run docker-compose commands against the certain containers only.

This is useful when you need for example to re-build just one container described as a service in a Docker Compose file.

Cool Tip: How to run a docker-compose in the detached mode! Read more →

Docker Compose Command Against Single Service

To start (up), stop, restart or build a single service (container) using the Docker Compose, simply specify the name of the service against which to run the corresponding docker-compose command.

Start a single service:

$ docker-compose up <service_name>

Stop a single service:

$ docker-compose stop <service_name>

Restart a single service:

$ docker-compose restart <service_name>

Build a single service:

$ docker-compose build <service_name>

Cool Tip: How to specify a path to the Dockerfile in a Docker Compose! Read more →

Leave a Reply