Post

Docker, Docker-Compose and Portainer (/w Watchtower) - Debian 12

Docker is a platform designed to help developers build, share, and run container applications. Add Portainer to a web interface to have container management software to deploy, troubleshoot, and secure applications

Install Docker

1
sudo apt install curl -y
1
2
3
curl -fsSL https://get.docker.com -o get-docker.sh
chomod +x get-docker.sh
sudo ./get-docker.sh

Eliminate Sudo for Running Docker

1
2
sudo usermod -aG docker $USER
newgrp docker

Install Portainer

Create Portainer Data Volume

1
docker volume create portainer_data

Create Portainer

1
2
3
4
5
6
docker run -d -p 8000:8000 -p 9443:9443 \
  --name portainer \
  --restart=always \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  portainer/portainer-ce:2.20.1

Or use Docker Compose:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
services:
  portainer-ce:
    ports:
      - 8000:8000
      - 9443:9443
    container_name: portainer
    restart: always
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data:/data
# Image Latest Update: June 13, 2024
    image: portainer/portainer-ce:2.20.3
volumes:
  portainer_data: {}
networks: {}

Access the web interface:

1
https://server_ip:9443

Watchtower Install w/ SMTP Gmail

App-Specific Password

1
https://security.google.com/settings/security/apppasswords
1
2
3
4
5
6
7
8
9
10
11
12
docker run -d \
  --name watchtower \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e WATCHTOWER_NOTIFICATIONS=email \
  -e WATCHTOWER_NOTIFICATION_EMAIL_FROM=email_address \
  -e WATCHTOWER_NOTIFICATION_EMAIL_TO=email_address \
  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER=smtp.gmail.com \
  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=587 \
  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=your_gmail_address \
  -e WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=PASSWORD \
  -e WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2 \
  containrrr/watchtower

Or Use Docker Compose

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
services:
  watchtower:
    container_name: watchtower
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - TZ=America/Chicago
      - WATCHTOWER_NOTIFICATIONS=email
      - WATCHTOWER_NOTIFICATION_EMAIL_FROM=email_address
      - WATCHTOWER_NOTIFICATION_EMAIL_TO=email_address
      - WATCHTOWER_NOTIFICATION_EMAIL_SERVER=smtp.gmail.com
      - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PORT=587
      - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_USER=your_gmail_address
      - WATCHTOWER_NOTIFICATION_EMAIL_SERVER_PASSWORD=PASSWORD
      - WATCHTOWER_NOTIFICATION_EMAIL_DELAY=2
    image: containrrr/watchtower
networks: {}
This post is licensed under CC BY 4.0 by the author.