GUI for Docker running on a VPS | Setting up Portainer | Access on your local machine through SSH Tunnelling
To see what's happening in docker, we have Docker Desktop. But what if your VPS runs docker, do we have a GUI for that ? So I recently set up Portainer on my Ubuntu VPS to manage Docker containers through a web-based interface. Instead of exposing the Portainer dashboard directly to the public internet, I decided to access it through an SSH tunnel. Here's a quick walkthrough of how I got it…
Setting up a Graphical User Interface (GUI) for Docker running on a VPS is straightforward with Portainer. This Docker-based tool provides a web-based interface for managing Docker containers. To achieve this, Portainer was installed as a Docker container on an Ubuntu VPS.
The process begins by ensuring Docker is installed and running on the VPS. Once Docker is operational, Portainer Community Edition is pulled and started as a container. The container exposes the Portainer HTTPS interface on port 9443 locally and communicates with the Docker engine using the Docker socket.
A setup token is generated by Portainer, which is retrieved from the container logs and used for the initial setup. This token is crucial as it authenticates the setup process.
To access Portainer from a local machine without exposing port 9443 to the public internet, an SSH tunnel is created. This is done using the ssh command on the local machine, specifying the local and remote ports, as well as the VPS IP address. The SSH tunnel must remain active to maintain access.
Upon accessing Portainer through the browser, it is important to note that Portainer defaults to HTTPS. Therefore, the correct URL to access is https://localhost:9443.
After the initial setup, a user and password must be created. It is highly recommended to save this password in a password manager for security purposes.
The advantage of this setup is that Portainer is contained within a Docker container, providing an additional layer of security by not exposing the dashboard publicly. Portainer's dashboard is accessible through the SSH tunnel, utilizing the existing SSH access to securely reach the dashboard. To enhance security, ensure that port 9443 is blocked from public access in the VPS firewall, as mounting /var/run/docker.sock grants Portainer extensive control over Docker on the VPS, necessitating secure administration of its credentials.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.