Docker on Debian
Page content
Let’s Setup Docker on Debian
- https://docs.docker.com/engine/install/debian/
- https://www.youtube.com/watch?app=desktop&v=PgICQblfWeY
Get Debian on some Cloud Provider
Update Apt
apt-get install ca-certificates curl gnupg lsb-release
add official GPG Keys
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg |gpg --dearmor -o /etc/apt/keyrings/docker.gpg
add Repo to Sources
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" |tee /etc/apt/sources.list.d/docker.list > /dev/null
install Docker Engine
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Check Version
docker version
root@docker:~# docker version
Client: Docker Engine - Community
Version: 20.10.18
API version: 1.41
Go version: go1.18.6
Git commit: b40c2f6
Built: Thu Sep 8 23:12:08 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Docker Compose Version
docker compose version
root@docker:~# docker compose version
Docker Compose version v2.10.2
Install Hello World
docker run hello-world
Prepare Folders
mkdir -p /etc/docker/container/traefik
cd /etc/docker/container/traefik
Build Docker-compose
cat << 'EOF' > docker-compose.yml
services:
traefik:
image: traefik:v2.6
restart: always
command:
- "--providers.docker"
- "--providers.docker.exposedByDefault=false"
- "--providers.docker.network=traefik_web"
- "--entrypoints.http.address=:80"
- "--entrypoints.http.http.redirections.entrypoint.to=https"
- "--entrypoints.http.http.redirections.entrypoint.scheme=https"
- "--entrypoints.https.address=:443"
- "--entrypoints.https.http.tls.certResolver=le"
- "--certificatesresolvers.le.acme.tlschallenge=true"
- "[email protected]"
- "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./letsencrypt:/letsencrypt
networks:
web:
name: traefik_web
EOF
docker compose up
docker compose up -d
docker compose ps
docker compose ps
NAME COMMAND SERVICE STATUS PORTS
traefik-traefik-1 "/entrypoint.sh --pr…" traefik running 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp
Demo Nginx
mkdir -p /etc/docker/container/nginx-demo
cd /etc/docker/container/nginx-demo
docker-compose.yml
cat << 'EOF' > docker-compose.yml
services:
nginx:
image: nginx:1.20
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx.rule=Host(`nginx.v4.docker.noflow.ch`)"
networks:
- traefik_web
networks:
traefik_web:
external: true
EOF
Nginx up
docker compose up -d
Tail logfile
docker compose logs -f
-> https://nginx.v4.docker.noflow.ch
NOTES: had some troubles as the Server is DualStacked and the FQDN got resolved to IPv4 and IPv6. So, Let’s Encrypt tried to reached the Server via IPv4 and IPv6 and could not reach Traefik via IPv6. Hence, le was not providing a Certificate.
apache container
cat << 'EOF' > docker-compose.yml
services:
apache:
image: php:8.1-apache
labels:
- "traefik.enable=true"
- "traefik.http.routers.apache.rule=Host=(`apache.v4.docker.noflow.ch`)"
networks:
- traefik_web
volumes:
- ./html:/var/www/html
networks:
traefik_web:
external: true
EOF
mkdir html
echo '<?php phpinfo(); ?>' > html/index.php
-> https://apache.v4.docker.noflow.ch
Any Comments ?
sha256: 423bee4d1634726649877bd0238a17993d7b7a1b10815aa7140127de5c97e701