Docker for Dummies /s

There's a lot of guides out there on how to configure Docker. I wanted to take an approach that outlines how I set up docker specifically in my environment, with both Virtual Machines and Proxmox containers.

I think for anyone getting into Docker, it is a bit of a learning curve to understand exactly what is happening. At least it was for me, hence the title. We'll configure Dockhand in this tutorial.


What is Docker?

At a high level, Docker is a cool way of running applications, or several applications at once, in a yaml file.


I typically run Ubuntu server OS for my virtual machines and containers. This will show the process I use specifically to install docker on a new host and begin configuration of the yaml file

Everything I do follows the install guidelines at https://docs.docker.com/engine/install/ubuntu/

(This assumes you have your username, and IP of the server you are remoting into.)

Install latest updates on the Ubuntu host:

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y

Setup repository for Docker, copy and paste this into your VM:

# Add Docker's official GPG key:
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

Install docker:

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

That's basically it. Docker will be installed and you'll be ready to setup your first yaml. Your yaml file is what docker runs off of.

You'll want to add whatever user you are currently and add to the docker group:

sudo usermod -aG docker $USER

Then log out and log back in get the associated permissions.

Setting up your first application

I typically make a dedicated directory for my docker installation. This keeps things tidy and I always know where to go for my docker compose file.

sudo mkdir /opt/docker-apps

Then you can create your compose yaml file:

nano /opt/docker-apps/compose.yaml

As you're getting into docker, my personal favorite for managing docker instances is called Dockhand. We'll set up Dockhand in our compose.yaml file:

services:
  dockhand:
    image: fnsys/dockhand:latest
    container_name: dockhand
    restart: unless-stopped
    ports:
      - 3000:3000
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - dockhand_data:/app/data

volumes:
  dockhand_data:

Press "control+x" and then "y" to save your configuration.

Then to run your config and start up Dockhand, launch the docker compose up -d command:

docker compose -f /opt/docker-apps/compose.yaml up -d

You can check the status of your running docker containers by running:

docker compose ps

You can also navigate to your server IP in your browser with :3000 at the end, and dockhand should be there!

The nice thing about docker is you can configure as many "services" or applications as you want per compose.yaml. It's up to you to decide how you want to configure it.

For instance, I have basically one application per compose.yaml file, so when I update or perform other maintenance, my other services are not impacted. For my *arr stack, I have multiple services grouped together in the same compose file, since maybe one service relies on another service being within the same docker network.

If you get into deploying dockhand, you'll need to add the hawser agent service to your other docker containers. But that's a blog for another day.

Hope this was helpful!