H2S Forum

Docker Compose common commands

Here are some of the commands that are commonly used when using Docker Compose.

1) docker-compose up

Used to deploy a Compose app.

By default this command reads a file named docker-compose.yml or docker-compose.yaml.

Of course, users can also specify other file names with -f. Normally, the app is started in the background with the -d parameter.

2) docker-compose stop

Stop all containers associated with the Compose app, but they will not be deleted.

A stopped application can be easily restarted with the docker-compose restart command.

3) docker-compose rm

Used to delete a stopped Compose app.

It deletes containers and networks, but does not delete volumes and mirrors.

4) docker-compose restart

Restart the stopped Compose app.

If the user changes the app after stopping it, the changed content will not be reflected in the restarted app, and the app needs to be redeployed for the change to take effect.

5) docker-compose ps

Used to list individual containers in a Compose app.

The output includes the current state, commands that the container runs, and network ports.

6) docker-compose down

Stop and delete the running Compose app.

It deletes containers and networks, but does not delete volumes and mirrors.