Portainer Tutorial: How to Update [and Restart] Portainer
In this tutorial, I will demonstrate how to manage Portainer. I’ll show you how to update Portainer, how to restart Portainer, and update existing containers with specific examples for each.
#What is Portainer?
Founded in 2017, Portainer is an open-source and lightweight container management UI that allows you to deploy and manage Docker containers seamlessly. It provides a simple and intuitive web UI for centralized management of Docker resources. With Portainer, you can deploy and manage containers and other Docker resources across Docker, Swarm, Azure ACI, and Kubernetes clusters.
#Why use Portainer?
The Docker CLI is usually the standard approach when deploying and working with containers and Swarm clusters. It’s fast, efficient and reliable. However, the Docker CLI is not always ideal especially for beginners and users not accustomed to working on the command line. It requires mastery of several commands and command-line options which can be daunting and tedious.
A more intuitive approach for container management is Portainer. With over 28,000 GitHub stars, Portainer is a popular GUI tool for creating and managing containerized applications.
Ready to supercharge your Docker infrastructure? Scale effortlessly and enjoy flexible storage with Cherry Servers bare metal or virtual servers. Eliminate infrastructure headaches with free 24/7 technical support, pay-as-you-go pricing, and global availability.
#What is Portainer used for?
Portainer aims to reduce the complexity involved in administering containers and other resources. Its user-friendly UI lets you perform container management tasks which would otherwise be tedious to perform on the CLI. Some of the management tasks you can execute include:
Deploying and managing containers (starting and stopping containers, recreating containers);
-
Pulling images from various repositories;
-
Creating and managing Docker volumes, templates, tech stacks, and networks;
-
Adding various registries for creating containers;
-
Centralized user management and access control;
-
Adding and managing various environments such as Swarm and Kubernetes;
-
Viewing event logs.
#Where is Portainer data stored?
Portainer stores its data in the _data
directory. By default, this directory is located in the /var/lib/docker/volumes/volume_name/
path whereby volume_name
is an auto-generated Portainer volume that appears as a long alphanumeric value.
Use the ls
command to confirm the directory location.
When a Portainer container is created with a persistent volume, the _data
directory is mounted in the path of the persistent volume.
For example, you can create a persistent volume called portainer_data
.
docker volume create portainer_data
Then deploy a Portainer container using the persistent volume as shown.
docker run -d -p 9000:9000 --name portainer_ce --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
In this case, the _data
directory will be in the /var/lib/docker/volumes/portainer_data
path.
#How to update and restart Portainer
The following sections will focus on various Portainer management tasks, including how to update Portainer and how to restart Portainer. Lastly, I will conclude by showing you how to update containers in Portainer.
#1. How to update Portainer?
Like most container images, the development team behind Portainer periodically releases newer versions to keep the application safe, secure, and at optimal performance. With that in mind, you want to ensure that your Portainer instance is always up to date.
Sometimes when you log in, you’ll notice a banner in the home page section indicating the availability of a newer version. For instance, the banner below announces that Portainer 2.19 is available and it’s time for an upgrade.
Since Portainer runs as a container, you simply cannot update it like you would any other software package. Instead, you need to stop and remove the container, and then redeploy it.
For this to work out, seamlessly deploy a Portainer with persistent volume. This implies that when you deploy Portainer, all your data and configurations will remain in place.
Now let us update Portainer.
First, stop the Portainer container using the container ID or container name. In this instance, we are removing the container by invoking the docker stop
command followed by the container ID.
docker stop container_ID
Next, remove the container.
docker rm container_ID
Once the container has been removed, download the latest Portainer image using the docker pull
command:
docker pull portainer/portainer-ce:latest
With the image in place, deploy a new Portainer container instance from the downloaded image as follows.
docker run -d -p 9000:9000 --name portainer_ce --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
NOTE
The re-deployment of Portainer does not affect other pre-existing containers, images, or Docker resources. Everything remains the same. Remember that Portainer runs as a separate container, independent from others.
Once deployed, launch your browser and log in using the same login credentials you used in the first deployment.
#2. How to restart Portainer?
Sometimes you might need to restart your Portainer deployment. This can happen when your Portainer instance is timed out for security purposes or any other reason.
Since Portainer runs as a container, you can restart it as you would any other container using the docker restart
command followed by the container ID or container name.
docker restart container_ID
OR
docker restart container_name
Alternatively, you can take the long route of stopping and starting the container.
docker stop container_ID
Then start the container.
docker start container_ID
#3. How to update containers in Portainer?
Having looked at how to update Portainer, let’s now switch gears and explore how to update containers with Portainer.
Portainer has made it easier to update containers with a few easy steps. For demonstration, we will update the Nginx container which is already deployed.
The first step is to stop the container. So, click the checkbox to mark the container and then click the Stop
button.
The container takes just a few seconds to stop and once stopped, its state will change from running
to exited
.
Next, click the container name, in this case, Nginx
.
In the pop-up window that appears, click Recreate
.
On the pop-up that appears, toggle on the Re-pull image
selection and click Recreate
.
Portainer will remove and re-create the container with a new updated image from the Docker registry. Once that is done, the container will kick back to life and appear, once again, on the container list.
Explore how web hosting service provider Debesis improved its service quality, performance, and reliability by migrating to Cherry Servers' bare-metal servers.
"Cherry Servers engineers always help when we need them, while their customer service quality is a blast!"
#Conclusion
Portainer is a game-changer in container management. It simplifies deployments and gives a more intuitive picture of the resources currently running on your Docker, Swarm, or Kubernetes environment. It’s without a doubt an ideal UI management platform for managing Docker resources for admins of all skill levels; from beginners to experts. Check out the official Portainer documentation for more information.
Cloud VPS - Cheaper Each Month
Start with $9.99 and pay $0.5 less until your price reaches $6 / month.