Skip to content

Docker

Installing Docker on a Debian-based Linux system is a straightforward process, but ensuring that all dependencies, keyrings and configurations are correctly set up is crucial for a smooth installation. This guide walks you through the steps needed to install Docker, add users to the Docker group and finalize the setup for managing containers on your Debian system. By the end of this guide, your system will be fully ready to run Docker containers efficiently and securely.


Docker Desktop is the recommended way to run Docker on macOS and Windows, as it provides an easy-to-use interface and built-in tools for managing containers.

For Linux, Docker Desktop is not required. Instead, you can install the Docker Engine (see below) directly, which provides all the necessary functionality without the additional overhead of Docker Desktop.


  1. Before installing Docker, ensure your system has all the necessary dependencies. This step installs packages that are essential for Docker to function properly on Debian Linux.

    Terminal window
    sudo apt install ca-certificates curl -y
  2. Docker requires keyrings to authenticate the software packages during installation. This step ensures that your system has the appropriate keyrings installed to verify Docker’s official package sources.

    Terminal window
    sudo install -m 0755 -d /etc/apt/keyrings
  3. Add the official Docker GPG key to your system’s keyring. This ensures that packages you download are verified as authentic and from the trusted Docker repositories.

    Terminal window
    sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
  4. Modify the file permissions to ensure Docker’s configuration files and directories are properly accessible. This step is essential for maintaining system security and ensuring Docker operates smoothly.

    Terminal window
    sudo chmod a+r /etc/apt/keyrings/docker.asc
  5. Add Docker’s official repository to your APT sources. This will allow you to install Docker directly from Docker’s official repository, ensuring you get the latest version.

    Terminal window
    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
  6. Run an APT update to refresh your package database and include the new Docker repository. This ensures that your system recognizes Docker as an available package for installation.

    Terminal window
    sudo apt update

Install the Docker Engine on your system. This command downloads and installs the latest stable version of Docker, enabling you to start using Docker on your Debian system.

Terminal window
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
  1. Add your user to the docker group. This allows you to run Docker commands without needing sudo each time, streamlining the Docker management process.

    Terminal window
    sudo groupadd docker
  2. Modify user permissions to ensure they have the necessary access rights to interact with Docker.

    Terminal window
    sudo usermod -aG docker $USER
  3. Finally, reboot your system to ensure all changes take effect.

    Terminal window
    sudo reboot
  1. Stop the Docker service.

    Terminal window
    sudo systemctl stop docker
  2. Move docker data to the new directory.

    Terminal window
    sudo mv /var/lib/docker {{EXTERNAL_HDD_PATH_VAR}}/docker-data
  3. Terminal window
    sudo nano /etc/docker/daemon.json
  4. Modify the Docker daemon settings to use the new directory.

    /etc/docker/daemon.json
    {
    "data-root": "{{EXTERNAL_HDD_PATH_VAR}}/docker-data"
    }
  5. Restart the Docker service.

    Terminal window
    sudo systemctl daemon-reload && sudo systemctl restart docker
  6. Check if Docker is now using the new directory.

    Terminal window
    # Docker Root Dir: {{EXTERNAL_HDD_PATH_VAR}}/docker-data
    docker info | grep "Docker Root Dir"