Install Portainer
Tired of using docker in cli and want a webui to help manage things? Here we go.
Bring up the Portainer image
We’ll go with what the Portainer docs say except for one tweak. Portainer sets the image to restart: always and for me I like restart: unless-stopped. This way if I stop the container it stays stopped until I start it again. First create a volume for the Portainer data then run the Portainer image.
Inside the Docker VM just built and as your user run:
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=unless-stopped -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:lts
Next browse to http://localhost:8000 or use the host IP:8000 and you’ll be greeted with the Portainer screen to create the administrator account. Follow the prompts to set up your admin account then click Get Started so it uses the local install.
Next screen you’ll see the local environment and you can start managing your containers. First click edit next to the Disconnect button and enter the host IP in the Public IP field, otherwise when you click the exposed port you’ll get sent to 0.0.0.0:PORT.
Bring up a Nginx image to test this install
Before we turn up nginx, let’s give it something to serve. Run the following commands to create a test html file. Change the path to wherever you want to serve the file from.
mkdir /home/username/html
cd /home/username/html
cat << EOF > index.html
<!DOCTYPE html>
<html>
<head>
<title>Hello, Nginx!</title>
</head>
<body>
<h1>Hello, Nginx!</h1>
<p>This is a test page served by Nginx in a Docker container.</p>
</body>
</html>
EOF
In the Portainer webui, click Stack in the left menu then click Add Stack. Name the stack (nginx) and paste the following into the editor. Change the volume path on the left side of the colon to the directory you want to serve the test file from.
services:
nginx:
image: nginx:latest
ports:
- "8080:80"
volumes:
- /home/username/html:/usr/share/nginx/html
restart: unless-stopped
Scroll down, under actions click Deploy the stack. Once the stack is deployed click on the stack name then click on the nginx service. You’ll see the Stack details. Under Published Ports, click on 8080 and it should open the test page.
What’s next? Rewind this and start with a Proxmox server or cluster in HCI then build up with networking, firewalls and templates using Ansible, Packer, Terraform, etc…? Continue with Docker plus Portainer and configure swarm? Create content on YouTube keeping this site for copy/pasta? Let me know, email me [email protected] .