Visualizing Your Docker Environment
Managing Docker via the command line (docker ps, docker logs, docker exec) is standard practice, but it becomes incredibly cumbersome when you have dozens of containers running across multiple servers. Portainer is a lightweight, open-source management UI that runs as a Docker container itself. It provides a beautiful web dashboard that allows you to start, stop, delete, and inspect containers, view real-time logs, open terminal consoles, and deploy full Docker Compose stacks entirely from your web browser.
Step 1: Install Docker
Before you can run Portainer, you must have the Docker engine installed on your Linux server (e.g., Ubuntu).
sudo apt update
sudo apt install docker.io docker-compose -y
sudo systemctl enable --now docker
Step 2: Create a Docker Volume for Portainer
Portainer stores its own configuration, user accounts, and environment data in a database. You must create a persistent Docker volume for this data so that it survives if the Portainer container itself is ever deleted or updated.
sudo docker volume create portainer_data
Step 3: Deploy the Portainer Container
Portainer is deployed by running a single, specific docker run command. You must expose port 9000 for HTTP access (or 9443 for HTTPS), mount the persistent volume you just created, and critically, mount the server’s Docker socket (/var/run/docker.sock). Mounting the socket is what gives the Portainer container the permission to manage the underlying Docker engine.
sudo 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
Step 4: Perform the Initial Web Setup
Open your web browser and navigate to your server’s IP address on port 9443 (e.g., https://192.168.1.50:9443). You will receive a self-signed certificate warning; bypass it.
The initial setup screen will require you to create an admin password. Note: For security reasons, if you do not create this password within 5 minutes of starting the container, Portainer will automatically shut itself down. You will need to restart the container (docker restart portainer) to try again.
Step 5: Navigate the Dashboard
Once logged in, click on the Local environment (this represents the server you just installed Portainer on).
Click on Containers in the left sidebar. You will see a graphical list of every container running on the system (including Portainer itself).
From this UI, you can click the checkbox next to a container and hit the Stop, Kill, or Restart buttons at the top. If you click on a specific container’s name, you can click the Logs icon to view its live standard output, or click the Console icon (>_) to instantly open a root shell inside the container directly in your web browser. You never have to memorize a docker exec command again.