Getting Docker up and running is extremely easy thanks to PhotonOS provided by VMware. Although they created it for ESXi, it works perfectly on Proxmox as well. Portainer is a web portal to administer your Docker containers, as Docker itself is only command-line.
This is extremally easy, as most settings can be set to your liking. I will be using ESXi for this guide.
For the OS-specific settings, select ‘Create new VM’, provide a VM name, select the latest version of ESXi VM, Select Linux for OS family, and finally Select PhotonOS at the bottom of the list for OS version. After selecting the storage to create the VM on, it comes down to client resources. I typically give it generous CPU cores and RAM as this can be reduced after installing all the initial containers, my default for a small Docker install is 4 CPU cores, 8GB RAM, and 20GB of storage. After you have your environment fully setup and ready for production, you can easily lower this to 1 CPU, 4GB RAM if you are tight on resources. PhotonOS requires at least 2GB RAM, but I like to give it a little headroom if possible to account for additional container requirements. The minimal install only takes up around 520mb of storage, but unless you want to get into the command line to expand your partitions, I just prefer to manually set it larger ahead of time. 20GB of space nowadays is pretty easy to set aside for a VM, and it gives you ample space to allocate to containers.
Once the VM has been created go ahead and click the console window to start the VM and enter console mode. Setup is pretty straightforward. I select ‘Photon Minimal’, select ‘VMware hypervisor optimized’ for ESXi, configure the network either with DHCP or select your static info, create root password, and done! It’ll reboot on successful install, and bring you to the login screen. Log in with root and the password you set during install.
enabling Docker and installing Portainer is super simple.
systemctl start docker
systemctl enable docker
Docker is now running and enabled to run at boot. Now it’s time to create a container for Portainer, and install it.
docker volume create portainer
docker run -d -p 9000:9000 --name Portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer:/data portainer/portainer-ce
Ignore that in my snippet I named the container portainer_data, it doesn’t matter as long as the created container matches the install string.
the install code sets the port to 9000, to start and restart always, it’s using the docker process, the name and location of the container, and the container install to download from docker.io. Honestly this install process is similar for most things, just setting the install string to each different install. Portainer is now installed an can be accessed on port 9000 of your VM.
Use the ‘ip address‘ command to find your VMs IP, then enter it in your brower to access the Portainer site to finish setup. The IP should be listed under eth0 on the line that starts with ‘inet’.
ip address
http://'HOST-IP':9000/
Create a password for the admin account, then create user. This is different than your docker login info, as this is only for the Portainer administration page. Portainer has the ability to graphically manage your container installs, and to create or destroy them as well. It’s useful to troubleshoot port issues and install containers with a simple input. You can browse the different containers at hub.docker.com to see what possibilities there are and what projects you can choose.
-=OPTIONAL STEP=-
I prefer to enable SSH on PhotonOS as well, it makes it much easier to use the CLI and gives you the ability of using a desktop client instead of the ESXi console. For setting this up we need to go back to the console window and edit the host SSH file. For this you can use the VIM editor that came with PhotonOS, but I prefer to use Nano.
To install Nano, just type:
yum install nano
Once that’s installed, we need to edit the host SSH file. When you open it for editing, just scroll all the way to the bottom of the document and change the ‘PermitRootLogin’ to yes.
nano /etc/ssh/sshd_config
Once the change is done, hit CTRL+O, hit enter, then CTRL+X. Now restart SSH with:
systemctl restart sshd
you can now access your PhotonOS install with SSH using port 22.
That’s it! You now have a fully functional Docker VM, with Portainer running and allowing a GUI for administration, AND SSH access.
One thought on “Setting up Docker with Portainer and SSH”