In this post, we will see how we can run Portainer in order to manage our Docker containers. Portainer offers a Web UI that we can use to build and manage containers in Docker, Swarm, Kubernetes and Azure ACI. If you have not already, see how to install Docker on your Ubuntu/Debian server.

Portainer comes in two flavours Portainer CE and Portainer Business.

  • Portainer CE is open source, free forever and used by more than 500,000 developers worldwide.
  • Portainer Business builds on CE and adds business related functionality.

We will deploy Portainer CE on our Ubuntu Server using Docker containers. Portainer is comprised of two elements, the Portainer Server, and the Portainer Agent. We will run only the Portainer Server without the Portainer Agent for simplicity as we don’t need the features of the Agent right now.

Portainer Deployment

Use the following Docker commands to deploy the Portainer Server:

docker volume create portainer_data
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

The first command creates a new portainer_data volume under /var/lib/docker/volumes in order to store persisting data for the docker container.

The second commands starts the docker container and binds the host’s 8000 and 9443 ports:

  • 9443 is used for the Portainer Web UI
  • 8000 is optional and only needed if we plan to use the Edge compute features with Edge agents

Initial Set Up

Once Portainer is deployed and you have navigated to http://ip-server:9443, you will see the following screens:

  1. The first thing to do is set a password for the admin user. This password needs to be at least eight characters long.
  2. You can disable the collection of statistics if you want.
  3. We will choose to Connect Portainer to manage the local Docker environment.
  4. Once the appropriate option is selected, click connect. If everything works as expected, You will then be shown the Portainer home page.

Upgrading to latest version

If there is a newer version available, to upgrade we need to remove the current container and pull the new image.

First, stop the container:

docker stop portainer

and remove it:

docker rm portainer

We can also remove the used image:

docker rmi portainer/portainer-ce:latest

Now we can run the container again and it will pull the latest image:

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