# Docker

# Installing Docker on Debian 13 (Trixie)

#### Step 1: Update the Package Index and Install Dependencies

```bash
sudo apt update
sudo apt install ca-certificates curl
```

#### Step 2: Import Docker’s Official GPG Key

```bash
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
```

#### Step 3: Add the Docker APT Repository

```bash
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian trixie stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list
```

#### Step 4: Install Docker Engine

```bash
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

#### Verify the Docker Installation

```bash
sudo systemctl status docker
```

The output will look something like this:

```bash
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running)
...
```

#### Run Docker Commands Without sudo

By default, only root and users with sudo privileges can run Docker commands.  
To allow a non-root user to execute Docker commands, add the user to the docker group:

```bash
sudo usermod -aG docker $USER
```

$USER is an environment variable that holds the currently logged-in username. To add a different user, replace $USER with the username.

Run newgrp docker or log out and log back in for the group membership change to take effect.

#### Verifying Docker with a Test Container

To verify that Docker is installed correctly and works without sudo , run a test container :

```bash
docker container run hello-world
```

If the image is not found locally, Docker will download it from Docker Hub, run the container, print a “Hello from Docker” message, and exit.

```bash
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
...
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
```

The container stops after printing the message because it has no long-running process.

#### Conclusion

Installing Docker on Debian 13 from the official Docker repository ensures you always have access to the latest stable releases and security updates. Once installed, add your user to the `docker` group to run commands without `sudo`.

For advanced configuration, check the [official Docker post-install guide .](https://docs.docker.com/engine/install/debian/)