# Set Up

The **installation,** **configuration** and some **tips** about Docker.

# Docker Installation on Raspberry Pi 4 / RaspberryPi OS

*The Docker installation is pretty straighforward, just follow the official tutorial on docker.com.*

---

## Adding the repository

Firstly, you need to add the repository of the Docker Engine:

```bash
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
```

## Installing the packages

Then, you can finally install the packages themselves with:

```bash
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

## Testing your installation

And lastely, to make sure your installation is flawless, run the hello-world test container using the following command:

```bash
sudo docker run hello-world
```

# Docker Commands to Remember

*This article is a list of some Docker commands you should keep in mind.*

---

<p class="callout info">
  1. docker exec <br>
</p>

---

## `docker exec`

- **Description**: execute a command in a running container
- **Usage**: `docker exec [OPTIONS] CONTAINER COMMAND [ARG...]`

### Description

The `docker exec` command runs a new command in a **running** container.

### Options

- `-d`, `--detach`: detached mode (run command in the background)
- `-i`, `--interactive`: keep STDIN open even if not attached
- `-t`, `--tty`: allocate a pseudo-TTY
- `-u`, `--user`: username or UID

### Examples

- **Execute an interactive `sh` shell inside *mycontainer*** : `docker exec -it mycontainer sh`
- **Execute an interactive `sh` shell inside *mycontainer* with the *root* user**: `docker exec -it --user root mycontainer sh`