docker compose restart Command

Docker command reference


The docker compose restart command is used to restart one or more services.

The docker compose restart command stops running service containers and then restarts them.

If you need to update configuration or simply want to restart services without rebuilding containers, then restart is very useful.

Syntax

docker compose restart [SERVICE...]
  • SERVICE(Optional): You can specify the name of one or more services to restart. If no service name is specified, all services defined in the docker-compose.yml file will be restarted.

Example

1. Restart all services:

docker-compose restart

2. Restart specific services (for example, services named web and db):

docker-compose restart web db

Ensure you execute these commands in the directory containing the docker-compose.yml file, or specify the location of the docker-compose.yml file via the -f parameter. For example, if your docker-compose.yml file is not in the current directory, you can specify the file location like this:

docker-compose -f /path/to/docker-compose.yml restart

This allows you to control which docker-compose.yml file is used to manage services.


Docker command reference

other extensions