Install Docker on Debian 12
🚀 One-Line Download & Execute
apt install -y curl & curl -sSL https://docs.greenhome.stream/attachments/34 -o install-docker-portainer.sh && chmod +x install-docker-portainer.sh && ./install-docker-portainer.sh
1. Install Docker on Debian 12
Before you install Docker Compose and Portainer, ensure that Docker is installed on your Debian 12 system.
Step 1: Update and Install Dependencies
apt update
apt install -y apt-transport-https ca-certificates curl software-properties-common
Step 2: Add Docker’s Official GPG Key
curl -fsSL https://download.docker.com/linux/debian/gpg | tee /etc/apt/trusted.gpg.d/docker.asc
Step 3: Add Docker's Official Repository
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list
Step 4: Install Docker
apt update
apt install -y docker-ce docker-ce-cli containerd.io
Step 5: Verify Docker Installation
docker --version
2. Install Docker Compose and Enable APT Updates
Step 1: Add Docker Compose APT Repository
Docker Compose is not included in the default Debian repositories, but you can use Docker’s official repository for Compose.
Create a Docker Compose APT repository source:
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list
Step 2: Install Docker Compose
Now, install Docker Compose from Docker's APT repository:
apt update
apt install -y docker-compose-plugin
This version of Docker Compose (the plugin version) integrates directly into the Docker CLI and will update with apt update and apt upgrade.
Step 3: Verify Docker Compose Installation
docker compose version
3. Install Portainer Using Docker Compose (Optional)
Portainer is a popular web UI to manage Docker environments. You can easily deploy it using Docker Compose.
Step 1: Create the docker-compose.yml File
Create a docker-compose.yml file in a directory where you want to manage Portainer. You can place it anywhere you like, but let’s say you create a directory called portainer :
mkdir -p ~/portainer
cd ~/portainer
Now create the docker-compose.yml file using your favorite editor:
nano docker-compose.yml
Paste the following content for the Portainer setup:
version: "3.9"
services:
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: always
networks:
- portainer_network
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
ports:
- 9000:9000
environment:
- TZ=Europe/Athens # Set your timezone
networks:
portainer_network:
driver: bridge
volumes:
portainer_data:
driver: local
Step 2: Start Portainer
Once the docker-compose.yml file is ready, run the following command to start Portainer :
docker compose up -d
This will pull the Portainer image, create the necessary containers, and start the Portainer web UI. You can now access it by going to http://<your-server-ip>:9000 in your web browser.
Step 3: Access Portainer
When you visit Portainer for the first time, you'll be prompted to set up an admin account. After that, you can start managing your Docker environment through the web interface.
4. Ensure Automatic Updates for Docker and Docker Compose
Since you added Docker’s official repositories, Docker Compose will be updated via the same process as Docker itself when you run :
apt update && apt upgrade -y
Summary
- Docker : Installed and running using the official Docker repositories.
- Docker Compose : Installed via Docker's APT repository and integrated with Docker.
- Portainer : Deployed using Docker Compose, with an example
docker-compose.ymlfile to start the Portainer service.
You should now have Docker, Docker Compose, and Portainer running on Debian 12, with updates managed through apt .