Skip to main content

Docker compose commands

Docker compose commands

Go to the folder where the docker-compose.yaml file is located, where you can execute the docker compose commands.

cd soffid4compose

In this tutorial, all commands are without sudo, if you need sudo do the Use docker without sudo.

Check the version.

docker compose version

Create or upgrade the containers, you must do it every time you modify the docker-compose.yaml file.

docker compose up -d

Check containers.

docker compose ps

Start, restart and stop a container

docker compose stop console
docker compose start console
docker compose restart console

Start, restart or stop all containers

docker compose stop
docker compose start
docker compose restart

View the console logs.

docker compose logs -f console

Destroy the containers

docker compose down

Enter into a container

docker exec -it console bash

Copy a file into a container

docker compose cp /soffid/mariadb-backup.sql mariadb:/tmp

 

Use docker without sudo

Follow the next steps.

CommandComment
sudo vi /etc/groupEdit the file
docker:x:988:YOUR-USERAdd your user at the end of the docker command
sudo systemctl restart dockerRestart the docker service
sudo usermod -aG docker YOUR-USERUpdate your user attributes 
exitExit to the ubuntu session
loginLog in into your docker session
docker psConfirm that you do not need to use sudo with a docker command