# 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**.

```shell
cd soffid4compose
```

<p class="callout warning">In this tutorial, all commands are without sudo, if you need sudo do the [Use docker without sudo](https://bookstack.soffid.com/books/utilities/page/docker-compose-commands#bkmrk-use-docker-without-s).</p>

Check the **version**.

```shell
docker compose version
```

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

```shell
docker compose up -d
```

**Check** containers.

```shell
docker compose ps
```

Start, restart and stop a container

```shell
docker compose stop console
docker compose start console
docker compose restart console
```

**Start**, **restart** or **stop** all containers

```shell
docker compose stop
docker compose start
docker compose restart
```

View the console **logs**.

```shell
docker compose logs -f console
```

**Destroy** the containers

```shell
docker compose down
```

**Enter** into a container

```shell
docker compose exec -it console bash
```

Copy a file into a container

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

### Use docker without sudo

Follow the next steps.

<table border="1" id="bkmrk-command-comment-sudo" style="border-collapse: collapse; width: 100%; height: 159.219px;"><colgroup><col style="width: 30.7737%;"></col><col style="width: 69.2263%;"></col></colgroup><tbody><tr style="height: 29.875px;"><td style="height: 29.875px;">**Command**</td><td style="height: 29.875px;">**Comment**</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">sudo gedit /etc/group

</td><td style="height: 29.7969px;">Edit the file with your editor (gedit for this example)</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">docker:x:988:YOUR-USER</td><td style="height: 29.7969px;">Add YOUR-USER at the end of the docker command without : at the end</td></tr><tr style="height: 29.875px;"><td style="height: 29.875px;">logout</td><td style="height: 29.875px;">Log out from the ubuntu session</td></tr><tr style="height: 29.875px;"><td style="height: 29.875px;">login</td><td style="height: 29.875px;">Log in into the ubuntu session</td></tr><tr style="height: 10px;"><td style="height: 10px;">docker ps</td><td style="height: 10px;">Confirm that you do not need to use sudo with a docker command</td></tr></tbody></table>