Files
docudjeex/content/3.serveex/2.coeur/2.docker.md

4.9 KiB
Raw Blame History

navigation, title, main
navigation title main
true Docker
fluid
false

:ellipsis{left=0px width=40rem top=10rem blur=140px}

Docker

Docker, to install deployable services in seconds and manage them with just a few commands or clicks.

::alert{type="info"} 🎯 Goals:

picture

Install Docker


Add the Docker repositories and GPG key:

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install 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

# Add the repository to Apt sources:
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
sudo apt-get update

Install the packages:

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

That's it!

More options: Install Docker for Debian 12

::alert{type="info" icon="exclamation-circle"} :::list{type="info"}

  • From here on, we assume the stacks are installed in the /docker folder, created using the command: :::
    sudo mkdir /docker
    

::

Install Dockge to manage and deploy containers


Dockge is a web tool to create, configure, launch, and manage Docker containers. It's a simple, intuitive interface thats lighter and easier for beginners than using the CLI or Portainer.

picture

Configuration

File structure we will create:

root
└── docker
    └── dockge    
        └── compose.yml

Create the stack folder:

cd /docker
sudo mkdir dockge

Then create the compose.yml file in this folder using vim:

cd /docker/dockge
sudo vi compose.yml

Press i to enter insert mode and paste the following:

---
services:
  dockge:
    image: louislam/dockge:1
    restart: unless-stopped
    container_name: dockge
    ports:
      - 3555:5001 # LAN-accessible port will be 3555

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /docker/dockge/data:/app/data
      - /docker:/docker
    environment:
      - DOCKGE_STACKS_DIR=/docker

Press Esc and type :x to save and exit.

To launch the container:

cd /docker/dockge
sudo docker compose up -d

Then go to http://yourserverip:3555 in your browser to access the login page.

More info on Dockge and how to use it

And there you go — Docker and a tool to easily manage your containers are ready!

Watchtower, to auto-update containers


Watchtower is a container that checks for updates and pulls new images automatically, just by adding a label in your containers compose.yml files.

Configuration

  • Open Dockge in your browser
  • Click compose
  • Name the stack watchtower
  • Paste the config below into the default config area in Dockge
---
services:
  watchtower:
    container_name: watchtower
    image: containrrr/watchtower:latest
    restart: unless-stopped
    env_file:
      - .env
    environment:
      - TZ=Europe/Paris
      - WATCHTOWER_SCHEDULE=${SCHEDULE}
      - WATCHTOWER_LABEL_ENABLE=true
      - WATCHTOWER_CLEANUP=true
      - WATCHTOWER_REMOVE_VOLUMES=true
      # Discord notifications - uncomment if used
      #- WATCHTOWER_NOTIFICATIONS=slack
      #- WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER=Watchtower
      #- WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL=${WH_URL}
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Then fill in the .env section in Dockge with the following:

SCHEDULE=
WH_URL=
Property Value Examples
SCHEDULE Cron format 0 0 6 * * * (every day at 6 AM)
WH_URL Your Discord webhook URL - append /slack at the end https://yourdiscordserver/webhook/slack

To have Watchtower monitor your other containers, add this to their compose.yml:

labels:
  - com.centurylinklabs.watchtower.enable=true

Then restart the modified stacks. And that's it — you now have a solid base to start deploying the services you want!