Installing Docker and Portainer on a Proxmox VM

This article will cover installing Docker and Portainer on a Proxmox VM, we created the VM in the previous article. There’s a bit of a shift in the home server Proxmox world over to using containers rather than Docker. Personally, I’m on the fence with this. On the one hand containers are good because they use fewer resources and can bind mount directories on the host. On the other hand it means much more set up. Even if the application you want to install is available on Turnkey it’s still going to be more work in the long run as major updates aren’t automatic. Docker, for me, feels more like a set up once and (almost) forget solution.

Installing Docker

Docker is pretty easy to install on Debian which is lucky because that’s what we’re using for our VM. In another stroke of good fortune the official documentation is also well written so there’s little point copying it in full here. I’ll be following the apt install path as that will provide the simplest way to keep the system up to date. Note that Docker pushes Docker Desktop quite hard, we want just the Docker Engine. Without further ado…

If after following the installation instructions you can run the Hello World container you’ve successfully completed the install and can move on to installing Portainer (or the Portainer Agent, see below). After installation you might want to add your user to the docker group, this will allow you to run docker without being root. This is, however, a security issue as it gives you root privileges, so use with caution. You should find that installing Docker has created the docker group, check /etc/group to be sure it’s there. Assuming it is from a root prompt add your user to the docker group.

usermod -aG docker doozer

You’ll need to at least log out and back in for this to take effect but I prefer to restart the VM. If docker run hello-world works then you’ve successfully added yourself to the group.

Installing Portainer Server

I’ve run Docker containers for years without a GUI but I’ve got to admit being able to just click a couple of buttons for an installation is nice to have. We’ll want Portainer CE (Community Edition) the documentation for which can be found here. To make things simpler the documentation asks you a few questions to get you straight to the correct install procedure. We want a new install on Docker stand alone and we want to install Portainer CE with Docker on Linux.

Interestingly, Portainer actually runs as a Docker container itself which makes the installation easy. You first create a volume for it to store it’s data in.

docker volume create portainer_data

The install the Portainer server container (check this is correct on the official site):

docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

This with create and start Portainer which will bind ports 8000 and 9443 and use a self-signed certificate. If you run docker ps you should see it running. If you visit port 9443 on your server you should now find Portainer running (e.g. https://media.example.co.uk:9443). You will be presented with the initial setup page.

On the initial setup page create a new user with a hard password, you don’t have to use the suggested name of admin. The system will then present you with the Environment Wizard since it automatically detects the local environment there is nothing else to setup, simply click Get Started.

Installing Portainer Agent

Multiple Docker installs can be managed from a single install of Portainer using the Portainer Agent. From the Portainer documentation rather than setting up a new server installation select Add an environment to and existing installation. This will guide you through installing the agent and connecting it to the existing Portainer install. Follow Add to existing > Docker stand-alone > Agent. The Portainer Agent requires port 9001 to be open.

The install process for the agent is incredibly smooth. Essentially you create a command on the Portainer server and run it on the machine you want to install the agent on and that’s it. If you select your new instance you should find that it has the Portainer Agent running and probalby the hello-world container. Test out the new environment by removing the hello-world container.

Other Tasks

If you have a Docker account you can add it through Portainer under Settings > Registries. Signing up for a free account just increases how many pulls you can do per-day.

Conclusion

That’s it, Docker and Portainer are installed. There’s a lot more to both of these tools but they are surprisingly intuitive and I mostly make it up as I go along.