Featured image of post Ubuntu 20.04 + Docker + Portainer on Proxmox

Ubuntu 20.04 + Docker + Portainer on Proxmox

My Ubuntu VM config.

NOTE This document is evolving as I’m still writing it. Reader beware!

Overview

I wanted to setup a small test system on my Proxmox host to test out cool, community Docker images I find online, such as the ones from LinuxServer.io.

I therefore created an Ubuntu box on my Proxmox host to test them out. This is how I did it.


Setup

Installing Proxmox

Download a Proxmox ISO and flash the image to a USB drive using an app like Balena Etcher.

Follow the setup instructions to install Proxmox to your machine.

Install Ubuntu

Downloading Ubuntu Server

I used Ubuntu Server 20.04.3 LTS as the distrubution for this setup.

If you are running a recent version of Proxmox VE (7.x or above) you can use the new ‘Download from URL’ function to download OS ISOs directly to the system.

  • Visit your Proxmox webUI
  • Click through Datacenter > “hostname” > local (hostname)
  • Click on ‘ISO Images’
  • Click ‘Upload’ and select an ISO image you downloaded to your local machine

OR

  • Click ‘Download from URL’ and paste in a URL for an OS image _(e.g. https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso)
  • Click ‘Query URL’
  • Click ‘Download’

Creating the VM

  • Click the blue ‘Create VM’ button in the top of the Proxmox webUI
  • Enter a name in the ’name’ field
  • Click on the ‘OS’ tab
  • Click on the ‘ISO Image’ drop-down and select the ISO image you downloaded previously
  • Click on the ‘Disks’ tab
  • Create a disk with a large enough size (I would recommend a minimum of 64GB - But you do you!)
  • Click on the ‘CPU’ tab
  • Explaining this section will be tricky, depending on your system hardware config. For my simple Mac mini host, I chose 1 Socket and 2 Cores
  • Click on the ‘Memory’ tab
  • Again, this section will very much depend on the hardware in your system. I chose to provide my VM with 8GB of RAM.
  • Click on the ‘Confirm’ tab
  • Click on ‘Finish’

Installing Ubuntu

  • Select the VM from the left hand side of the Proxmox webUI
  • Click the ‘Start’ button
  • Click the ‘Console’ button to view the display of your new VM
  • Follow the prompts from the Ubuntu installer to complete the installation (I kept things basic, not installing any additional software/Snaps etc.)
  • Once complete, the VM will reboot and you will be at a login prompt in the console

Enabling QEMU Guest Agent

There is a guide for this also available on the Proxmox Wiki

  • Select the VM from the left hand side of the Proxmox webUI
  • Click the ‘Shutdown’ button to shutdown the VM safely
  • Once complete, the VM name will be greyed-out on the left of the Proxmox webUI
  • Click the ‘Options’ tab within the VM settings
  • Click on ‘QEMU Guest Agent’ and double click on ‘Disabled’, ticking the box and pressing ‘OK’ to enable it
  • Start the VM again and connect via the console
  • Run the following commands:
    sudo apt update
    sudo apt install qemu-guest-agent
  • Reboot the guest OS either by command line or the Proxmox webUI
  • You will know things are working correctly once you can see the IP address for the machine in the ‘Summary’ page of the guest OS in the Proxmox webUI

Installing Docker

SSH from your local machine to the VM, or use a console through the Proxmox web interface.

  • Update your package lists: sudo apt update

  • Upgrade all the things: sudo apt upgrade

  • Install the dependencies:

1
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  • Import the GPG Key:
1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • Add the Docker repo:
1
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  • Update package lists again: sudo apt update

  • Install Docker: sudo apt install docker-ce docker-ce-cli containerd.io

  • Install Docker-Compose: sudo apt install docker-compose

  • Check Docker started okay: sudo systemctl status docker

  • Verify the installation by starting a ‘hello-world’ container: docker run --rm hello-world

Fixing “Permission denied” error running docker without root

  1. Create a group called “docker” with the following command (the group may already exist):
    • $ sudo groupadd docker
  2. Add your user to the docker group:
    • sudo usermod -aG docker $USER
  3. After you have added the user to the docker group, logout and back in for the changes to take effect. Otherwise, run the following command:
    • newgrp docker

Installing Portainer

  • Create a volume for Portainer to use: sudo docker volume create portainer_data

  • Now create the Portainer container:

1
sudo docker run -d -p 9000:9000 -p 8000:8000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /srv/portainer:/data portainer/portainer
  • Start the container: sudo docker start portainer
    Portainer should now be running on port 9000 on your host.
    Check the IP address of your host with: ip a or ifconfig

  • Visit the web UI for Portainer by visiting the IP with port :9000 (e.g. http://192.168.1.55:9000)

  • You’ll need to create a new password for the admin user on first login and press Create user.

  • Then on the next screen, select Local and press Connect.
    You should now be connected to your Portainer instance!

Built with Hugo
Theme Stack designed by Jimmy