Portainer Tutorial: How to Update [and Restart] Portainer

May 15th, 2024
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.

portainer-data-storage-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.

portainer-data-storage-location-in-persistent-volume

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.

portainer-new-version-notification

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

docker-stop-portainer-container

Next, remove the container.

docker rm container_ID

docker-remove-portainer-container

Once the container has been removed, download the latest Portainer image using the docker pull command:

docker pull portainer/portainer-ce:latest

docker-pull-portainer-image

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

docker-create-portainer-container

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

docker-restart-portainer-container

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

docker-stop-start-portainer-container

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.

docker-stop-nginx-container

The container takes just a few seconds to stop and once stopped, its state will change from running to exited.

docker-container-exited-portainer

Next, click the container name, in this case, Nginx.

docker-container-nginx-portainer

In the pop-up window that appears, click Recreate.

recreate-docker-container-in-portainer

On the pop-up that appears, toggle on the Re-pull image selection and click Recreate.

recreate-container-popup-in-portainer

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.

container-list-in-portainer

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.

Winnie is a seasoned Linux Systems administrator, currently specializing in writing technical Linux tutorials. With over seven years of experience in deploying and working with major Linux distributions such as Ubuntu, Debian, RHEL, OpenSUSE, and ArchLinux, she has written detailed and well-written "How to" Linux guides and tutorials. Winnie holds a Bachelor's Degree in Computer Science from Masinde Muliro University, Kenya and resides in Nairobi, Kenya. She is an expert in authoring Linux and DevOps topics involving Docker, Ansible, and Kubernetes. She currently works as a freelance technical writer and consultant. In her previous roles, she worked in the capacity of an IT support specialist and Linux administrator. Her key roles included offering level 1 and 2 support to both in-house and remote staff and managing and monitoring Linux servers.

Start Building Now

Deploy your new Cloud VPS server in 5 minutes starting from $5.83 / month.

We use cookies to ensure seamless user experience for our website. Required cookies - technical, functional and analytical - are set automatically. Please accept the use of targeted cookies to ensure the best marketing experience for your user journey. You may revoke your consent at any time through our Cookie Policy.
build: b0376f5bd.760