Installing Docker on Debian 12 Tutorial

,
Installing Docker on Debian 12

This tutorial guides you through the step-by-step process of installing Docker on Debian 12. Docker allows you to build, ship, and run applications in containers.

Step 1: Update the System

Ensure your system is updated to avoid compatibility issues.

  1. Open a terminal.
  2. Run the following commands:
apt update
apt upgrade -y

Step 2: Install Required Dependencies

Docker requires some prerequisites to function properly.

  1. Install necessary packages:
apt install -y ca-certificates curl gnupg lsb-release

Step 3: Add Docker’s Official GPG Key

Add the GPG key for Docker’s repository to ensure secure package installation.

  1. Create a directory for the GPG key:
mkdir -p /etc/apt/keyrings
  1. Download and add Docker’s GPG key:
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Step 4: Add the Docker Repository

Set up Docker’s repository for the Debian 12 package manager.

  1. Add the Docker repository to your sources list:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 5: Installing Docker on Debian 12

Now that the repository is configured, you can install Docker.

  1. Update the package list:
apt update
  1. Install Docker Engine, CLI, and Containerd:
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 6: Verify Docker Installation

Ensure Docker is installed correctly by checking its version.

  1. Verify the installation:
docker --version

Example output: Docker version 24.0.2, build cb74dfc

  1. Run the Docker Hello World container to test:
    If everything is working, you will see a message confirming Docker is installed and operational.
docker run hello-world
Installing Docker on Debian 12 Tutorial
Installing Docker on Debian 12

Step 7: Manage Docker as a Non-Root User (Optional)

By default, Docker requires root privileges. You can configure it to run without sudo.

  1. Add your user to the docker group:
usermod -aG docker $USER
  1. Log out and log back in to apply group changes.
  2. Test running Docker without sudo:
docker run hello-world

Step 8: Enable Docker to Start on Boot

Ensure Docker starts automatically when the system boots.

  1. Enable Docker:
systemctl enable docker

Conclusion

You have successfully installed Docker on Debian 12. Docker is now ready for use, and you can start building and deploying containerized applications. For further usage instructions, consult the official Docker documentation.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *