Docker helps define and install multiple container builds. It can be run as a command line interface or via Docker Compose which reads YAML files of configuration information allowing services that can be run-up or torn-down with ease.
Docker will run in an Ubuntu VM on Proxmox. Used this guide by credibleDEV on Youtube.
- Download Ubuntu Server LTS (ISO) to Proxmox Datacenter -> titan -> local -> ISO Images
Create VM
- In Proxmox, click Create VM
- General tab: Name = docker, tick Start at boot, click Next
- OS tab, select ISO Image above, remainder = default, click Next
- System tab, just click Next
- Disks tab, set Disk size = 32GiB, tick Discard and Advanced -> SSD emulation
- CPU tab, select Cores = 2, click Next
- Memory tab, set Memory (MB) = 4096, click Next
- Network tab, set MAC address =
- to retain IP reservation, click Next
- On the Confirm tab, uncheck Start after created, click Finish
Install Ubuntu Server
- Select newly created VM -> Console, click Start now to start the VM, server installs
- At the menu, select Try or Install Ubuntu Server,
- Set language = English (UK), click Enter
- If Installer update available, select Continue without updating
- Set keyboard layout = English (UK), click Done
- Select Ubuntu Server (minimised), click Done
- Select DHCP, reservation should get 192.168.0.22, click Done
- Leave Proxy address = blank
- Leave Mirror address = default
- For storage accept default Use an entire disk / Setup as LVM group, click Done
- At File System Summary, click Done, then Continue
- Setup credentials: Your name = admin, Server = docker, Username = [STRONGBOX], Password = [STRONGBOX], click Done
- On Upgrade to Ubuntu Pro screen, select Skip for now, click Continue
- On SSH Setup, tick Install OpenSSH Server option, click Done
- On Featured Server Snaps, just click Done
- Wait for installation to finish, then Reboot Now
- At Failed unmounting /cdrom, just press Enter
Install Docker
-
SSH into the server [email protected], enter PW, say yes to authenticity question, and run following commands to update Ubuntu
1 2
sudo apt update [enter password] sudo apt upgrade
- Just press enter at the services query
- Set the correct timezone for Docker host (defaults to UTC):
sudo timedatectl set-timezone Europe/London
- Confirm okay by:
timedatectl
- Go to the Docker page Installing docker engine on Ubuntu
- Copy the commands from that page to:
- Setup the repository:
- Update packages:
1 2
sudo apt update sudo apt-get install ca-certificates curl gnupg
- Add Docker’s official GPG key:
1 2 3
sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg –dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg
- Set up the repository
1 2 3 4
echo \\ “deb [arch=”$(dpkg –print-architecture)” signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \\ “$(. /etc/os-release && echo “$VERSION\_CODENAME”)” stable” | \\ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- Install Docker Engine:
- Update packages
1
sudo apt update
- Install Docker Engine, containers and Docker Compose
1
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Update packages
- Update packages:
- Verify installation successful
1
sudo docker run hello-world
- This command downloads a test image and runs it in a container, this prints a confirmation message and exits
- Setup the repository:
- Copy the commands from that page to:
Preparation for Docker Service Installs
-
Setup Folders and Files: setup the folder structure in the Docker container to support all the various apps:
1 2 3 4
cd ~ # go to home directory mkdir docker # make docker folder for Docker related data cd docker mkdir logs # central logs
-
Docker Root Folder Permissions: set permissions for the Docker folder, and give access to the docker group:
1 2 3 4
sudo apt install acl # only needed if "acl" not installed sudo chmod -R 775 ~/docker sudo setfacl -Rdm g:docker:rwx ~/docker sudo setfacl -Rm g:docker:rwx ~/docker
-
Setup Environment Variables & Permissions: frequently used information is kept in a common location and called up as needed using variable names:
1 2 3 4 5 6 7
cd ~/docker touch .env # create file (dot hides file in directory listings sudo chown root:root .env # set owner as root sudo chmod 600 .env # lock down permissions, edit as root only sudo apt install nano # Not installed with minimal Linux sudo nano .env
-
Add the following environment variables:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# SYSTEM PUID=1000 PGID=1000 TZ=Europe/London USERDIR=/home/docker_user DOCKERDIR=/home/docker_user/docker LOCAL_IPS=127.0.0.1/32,10.0.0.0/8,192.168.0.0/16,172.16.0.0/12 # DOMAIN DOMAINNAME_CLOUD_SERVER=bbproj.org CLOUDFLARE_EMAIL=[email protected] CLOUDFLARE_API_KEY=[STRONGBOX] CLOUDFLARE_API_TOKEN=[STRONGBOX] CLOUDFLARE_IPS=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.0/15,104.16.0.0/13,104.24.0.0/14,172.64.0.0/13,131.0.72.0/22 # APPS TRUENAS_SERVER_IP=192.168.0.10 PLEX_USER=plex PLEX_PASSWORD=[STRONGBOX]
-
These variables will be referred to as $VARIABLE_NAME through the various apps Docker compose files. Configure as follows:
- PUID / GUID: these need to be the User ID and Group ID of the Linux user (administrator) and can be obtained by id command. These will normally be 1000
- TZ: timezone can be obtained from timezone database (Wikipedia)
- USERDIR: home folder of the current user
- DOCKERDIR: docker root folder that stores all persistent data for docker apps
Install QEMU Guest Agent
This runs inside the VM Guest and allows the hypervisor to support additional functions about guest IP addresses, file systems, or suspending / rebooting. Install guide.
- SSH into the guest VM, and run the following:
- Update the package index
1
sudo apt update
- Download the QEMU guest agent
1
sudo apt install qemu-guest-agent
- Enable the service to start automatically on reboot
1
sudo systemctl enable qemu-guest-agent
- Update the package index
- In the Proxmox GUI, go to VM -> Options
- Double click on QEMU Guest Agent, select Use QEMU Guest Agent, click OK
- From the VM Shutdown menu, click Stop, confirm Yes
- When stopped click Start
- VM details such as IP addresses should appear in the VM summary page
Docker Socket Proxy
COULD NOT GET TO WORK, OMITTED
Docker and Docker Compose Usage
A few command line notes for Docker:
- Starting Containers
1
sudo docker compose -f ~/docker/<dc-appname>.yml up -d
- The .yml (YAML) filename can be anything relevant to the container(s) being built
- The -d option daemonises the command in the background. Without it you will see the real-time logs. If not used, use Ctrl-C to exit the real-time logs
- See Docker Containers
1
sudo docker ps -a
- This will show a list of containers with Status of each
- Check Docker Logs, one of
1 2
sudo docker compose -f ~/docker/<dc-appname>.yml logs sudo docker logs <container_name>
Once Portainer is installed that can be used to view and manage containers.
Resources
- Docker documentation