This page explains how to run Docker on Ubuntu 22.04. Portainer is a lightweight, open-source management UI for Docker. It allows users to manage and monitor Docker environments, including containers, images, networks, and volumes through a web-based graphical user interface. With Portainer, you can easily deploy, run, and manage containers, as well as configure and monitor the health of their Docker environments.
The following assumes Docker is already installed. If not, please read this page on how to install Docker on Ubuntu 22.04.
It also assume Docker can be used as non-root user.
The following has been tested with these versions:
Start by updating your system with the following command:
sudo apt update -y && sudo apt upgrade -y
Portainer needs persisting data (for storing user password for example). Let's create a docker volume to store this data:
docker volume create portainer_data
Once the volume is created, you can inspect the volume to get its location for example:
docker volume inspect portainer_data
Once the volume is created, run the following command to start portainer in a container:
docker run -d -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
Here is the detail of each option:
docker run
is the base command to start a container-d
means detach. It runs the container in background.-p
expose UI over the port 9000, portainer GUI will be at URL hostname:9000
--name=portainer
names the container portainer--restart=always
always restart Portainer (after a crash or at machine or deamon restart)-v /var/run/docker.sock:/var/run/docker.sock
mounts the volume /var/run/docker.sock
from the host machine to the Portainer container. /var/run/docker.sock
is actually the Docker daemon socket. Portainer needs this socket to get Docker status.-v portainer_data:/data
mounts the volume created previouslyportainer/portainer-ce
is the name of the Portainer Community Edition image.Docker should download and run the Portainer image:
$ docker run -d -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
Unable to find image 'portainer/portainer-ce:latest' locally
latest: Pulling from portainer/portainer-ce
772227786281: Pull complete
96fd13befc87: Pull complete
0bad1d247b5b: Pull complete
b5d1b01b1d39: Pull complete
Digest: sha256:f7607310051ee21f58f99d7b7f7878a6a49d4850422d88a31f8c61c248bbc3a4
Status: Downloaded newer image for portainer/portainer-ce:latest
e2d55a08eae21f03deb3e68f375b79f01a6956c00e68453b37dc2509682ff758
Once the image is launched, open your favorite web browser and go to the portainer URL localhost:9000
:
The first time Portainer starts, it asks you to set a password. The password must be at least 12 characters. Once the password is entered, the following page should appear in the browser:
Select Get Started (unless you need to connect to another environments).
You should see at least one environment named local
Select the local
environment, you should at least see
portainer
)portainer
)portainer_data
)Navigate through the user interface to discover all the possibilities of Portainer. Reboot the machine and check that Portainer is launched at startup.
That's all folks!