Table of Contents
Was this article helpful?

3  out of  4 found this helpful

Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles!

How to Install Portainer on Ubuntu 20.04 with Docker

Last Updated: Wed, Feb 3, 2021
Containers Kubernetes Ubuntu


Portainer is a powerful container management tool for Kubernetes and Docker. This tutorial explains how to install the Portainer with Docker on Ubuntu 20.04.


Example Names

This guide uses example names.

  • : Example domain with the correct DNS record to your instance.
  • Example email to receive Let's Encrypt reminders. Replace it with a real email address, or Let's Encrypt will not issue a certificate to you

1. Create a Container

Create a directory for the Portainer to store data, then create a Portainer container.

$ sudo mkdir -p /vol/portainer/data
$ docker run --restart always -d --name=portainer -v /var/run/docker.sock:/var/run/docker.sock -v /vol/portainer/data:/data -e -e VIRTUAL_PORT=9000 portainer/portainer-ce -H unix:///var/run/docker.sock
  • -v /var/run/docker.sock:/var/run/docker.sock means mounting /var/run/docker.sock to the container so portainer can control the Docker.
  • -v /vol/portainer/data:/data means storing data of portainer on directory /vol/portainer/data.
  • is your domain to access the portainer.

2. Configure Reverse Proxy for Portainer

HTTPS is a necessary security measure to protect your data from network hijacking. Caddy is a light ZeroSSL reverse proxy server. It means that you don't need to consider complex HTTPS configuration, it obtains and automatically maintains SSL certificates. This tutorial uses Caddy for reverse proxy Portainer.

Create a Caddyfile

Caddyfile is a document containing configs for your sites. Create a Caddyfile:

$ sudo mkdir -p /vol/caddy/configs
$ sudo nano /vol/caddy/configs/Caddyfile

Then populate it with the following text: {
    reverse_proxy portainer:8000
  • is your domain with the correct DNS record to your instance.
  • tls means apply free certificates and use this email to receive Let's Encrypt reminders.
  • reverse_proxy portainer:8000 means forward request to 8000 port on container portainer.

Press :KEYCTRL: + :KEYX: to save the file.

Create a Caddy Container

After compose the Caddyfile, create a container with the 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
  • -p 80:80 -p 443:443 means publish its 80 and 443 port to your host so you can access it with those ports.
  • -v "/vol/caddy/data:/data/caddy" means mount caddy working directory to your host to persist data such as certificates.
  • -v "/vol/caddy/configs:/etc/caddy" means mount caddy configuration directory to your host to persist configurations.
  • --link portainer means link container caddy with portainer so they can access with each other.

3. Install Portainer

Visit your domain in a web browser and set a password to finish the installment.

More Resources

Want to contribute?

You could earn up to $600 by adding new articles