system update operation and service maintenance network via engineer
Image: ontsunan/Adobe Stock

Portainer has been, for some time, my go-to container management platform. It’s not only very powerful, but it’s also quite user-friendly, and in the game of containers, that’s an impressive combination.

Portainer is deployed as a container itself. And with the development team frequently releasing new versions, you always want to make sure you stay on top of that. To that end, any time you log into your Portainer instance and notice that a new version is available (Figure A), it’s time to upgrade as soon as possible.

Figure A

My current Portainer deployment is out of date.

Because Portainer is a container, you can’t just update the current deployment; instead, you have to stop and remove your current deployment and redeploy. Fortunately, you can deploy Portainer with persistent storage (as I show in How to deploy the Portainer container management tool with persistent storage), which means when you redeploy all of your configurations and containers will remain intact.

With that said, let’s update Portainer to the latest version.

SEE: Hiring kit: Back-end Developer (TechRepublic Premium)

What you’ll need

To follow along, you’ll need a machine running Docker or Docker Community Edition. If you don’t already have a Portainer instance already up, you can still deploy the latest release, just skip the first steps of stopping and removing the older instance. You’ll also need a user who belongs to the docker group on your hosting server.

Let’s get to the update.

How to stop and remove the current Portainer container

The first thing you must do is located the Portainer container ID with the command:

docker ps -a | portainer

You should see something like this in the output:

0eab77c40087   portainer/portainer-ce      "/portainer"         4 weeks ago  Up 3 weeks      >8000/tcp, :::8000->8000/tcp,>9443/tcp, :::9443->9443/tcp, 9000/tcp         portainer

The random string of characters is the container ID (in the above case it’s 0eab77c40087). To stop and remove the container, you only need to use the first four characters. First, stop the container with:

docker stop 0eab

Make sure to change out the first four characters with those of your running Portainer container.

Next, remove the container with:

docker rm 0eab

How to deploy the new version

Before we run the deploy command, let’s first pull down the latest version with:

docker pull portainer/portainer-ce:latest

Once the new image has pulled down, deploy the latest Portainer version with:

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

Give the container time to deploy. After a minute or so, point your browser to http://SERVER:9443, where SERVER is the IP address of the hosting server, and log back into Portainer with the same credentials you used previously. You should see the new version has been deployed (Figure B).

Figure B

I went from version 2.13.1 to 2.14.1.

And that’s all there is to updating Portainer to the latest release. Because we originally deployed with persistent storage, this process is incredibly easy and painless.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.