Portainer is a management tool for Docker, Docker Swarm and Kubernetes. This tool allows to manage containers, images, volumes, networks, and more. Portainer provides dashboard that accessible to the user from a web browser. This tutorial demonstrates how to install Portainer on Ubuntu 20.04. Prepare environment. Make sure you have Docker in. In this blog post we are going to focus on Portainer Community Edition and how to install it an Ubuntu 18.04 box. Installing Docker. Portainer runs in a container, so we need to install and have Docker service running in our server. Installing docker is quite easy and straight forward especially if you are used to the linux environment. If you are new to Docker, you may wonder to have a GUI to manage your Docker. Unfortunately, Docker does not shipped with GUI.
In this article, we’ll explain how to install Portainer on Ubuntu 20.04 with Docker.
Portainer is powerful, open-source toolset that allows you to easily build and manage containers in Docker, Swarm, Kubernetes and Azure ACI. It works by hiding the complexity that makes managing containers hard, behind an easy to use GUI.
Always keep your server up-to-date for security purpose.
# apt-get update -y
Install the required dependencies for Docker:
# apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
Add the Docker CPG Key
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg sudo apt-key add -
Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.
# sudo apt-key fingerprint 0EBFCD88
pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) <[email protected]>
sub rsa4096 2017-02-22 [S]
Add the Docker Repository
# add-apt-repository 'deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable'
The following command will download Docker and install it:
# apt-get update -y
# apt-get install docker-ce -y
Start and enable Docker service
# systemctl start docker && systemctl enable docker
We’ll show you two ways to deploy the container.
1. If you want to use domain name to access Portainer, use following command to deploy the container:
# docker run --restart always -d --name=portainer -v /var/run/docker.sock:/var/run/docker.sock -v /vol/portainer/data:/data -e VIRTUAL_HOST=port.example.com -e VIRTUAL_PORT=9000 portainer/portainer-ce -H unix:///var/run/docker.sock
2. If you want to access Portainer using server IP, use following command to deploy the container:
# docker volume create portainer_data
# docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
Caddyfile is a reverse proxy server. It is necessary to secure the connection to prevent network hijacking. Caddyfile can obtains and automatically maintains SSL certificate.
Create a Caddyfile. Caddyfile is a document containing configs for your sites:
# mkdir -p /vol/caddy/configs
# vi /vol/caddy/configs/Caddyfile
Add following content:
tls [email protected]
Replace: port.example.com with your domain name and [email protected] with your actual email id.
Save and exit.
Finally, create a Caddy container using following command:
# docker run --restart always -d -p 80:80 -p 443:443 -v '/vol/caddy/data:/data/caddy' -v '/vol/caddy/configs:/etc/caddy' --link portainer --name caddy caddy
Navigate to your browser and access the Portainer by using either your domain or server IP and set admin password and finish the installment.
That’s it. The installation has been completed successfully.
In this article, we’ve have seen how to install Portainer on Ubuntu 20.04 with Docker.