If you’re looking to streamline your container management, Docker, Docker Compose, and Portainer are essential tools to have in your toolkit. In this guide, we’ll walk you through the steps to install and set up these tools on Debian 12. Whether you’re a developer, sysadmin, or hobbyist, this tutorial will get you up and running in no time!
Prerequisites
- A system running Debian 12.
- A user with sudo privileges.
- An active internet connection.
Step 1: Update Your System
Before installing anything, it’s always a good idea to update your system to ensure you have the latest packages and security patches.
sudo apt update && sudo apt upgrade -y
Step 2: Install Docker
Docker is the foundation for running containers. Let’s install it first.
1. Add Docker’s Official GPG Key
To ensure the authenticity of the Docker packages, add Docker’s GPG key:
sudo apt install -y 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
2. Add Docker’s Repository
Next, add Docker’s official repository to your system:
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
3. Install Docker Engine
Update your package list and install Docker:
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
4. Start and Enable Docker
Once installed, start the Docker service and enable it to run on boot:
sudo systemctl start docker
sudo systemctl enable docker
5. Verify Docker Installation
Check if Docker is running correctly:
sudo docker --version
You should see the Docker version displayed, confirming a successful installation.
Step 3: Install Docker Compose
Docker Compose is a tool for defining and running multi-container Docker applications.
1. Download Docker Compose
Download the latest version of Docker Compose:
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2. Make Docker Compose Executable
Set the correct permissions for Docker Compose:
sudo chmod +x /usr/local/bin/docker-compose
3. Verify Docker Compose Installation
Check the installed version:
docker-compose --version
Step 4: Install Portainer
Portainer is a user-friendly web interface for managing Docker environments.
1. Create a Docker Volume for Portainer
Portainer stores its data in a Docker volume. Create one:
sudo docker volume create portainer_data
2. Run Portainer as a Docker Container
Start the Portainer container:
sudo docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
3. Access Portainer
Open your web browser and navigate to:
http://<your-server-ip>:9000
Create an admin user when prompted, and you’ll be ready to manage your Docker environment through Portainer’s intuitive interface.
Step 5: Optional – Add Your User to the Docker Group
To run Docker commands without sudo, add your user to the docker group:
sudo usermod -aG docker $USER
Log out and log back in for the changes to take effect.
Conclusion
Congratulations! You’ve successfully installed Docker, Docker Compose, and Portainer on Debian 12. With these tools, you’re now equipped to deploy and manage containers with ease.
Whether you’re running a single container or orchestrating a complex multi-container setup, Docker and Portainer make the process seamless and efficient. Happy containerizing!
Need help? Leave a comment below or check out the official documentation for Docker, Docker Compose, and Portainer.
