Portainer is a powerful, open-source tool that provides a graphical interface for managing Docker. It simplifies the process of deploying and managing Docker containers, images, networks, and volumes. One of the key features of Portainer is its ability to update Docker containers, including itself, which is the focus of this guide.

Why Update Portainer?

Keeping Portainer updated is crucial for several reasons. Firstly, updates often come with new features and improvements that can enhance your Docker management experience. Secondly, updates often include security patches that fix vulnerabilities in the software, ensuring your Docker environment remains secure.

Checking the Current Version of Portainer

Before you begin the update process, it’s important to know which version of Portainer you’re currently running. This information can be found in the Portainer dashboard.

Accessing the Portainer Dashboard

To access the Portainer dashboard, open a web browser and navigate to the IP address of your Docker host on port 9000. Log in using your Portainer credentials.

Finding the Current Version

Once logged in, click on the ‘About’ section in the lower-left corner of the dashboard. Here, you’ll find information about your Portainer instance, including the current version number.

Stopping the Current Portainer Container

Before you can update Portainer, you need to stop the current running instance of the Portainer container. This is done using the Docker ‘stop’ command.

Using the Docker Stop Command

Open a terminal window and type the following command:

docker stop portainer

This command tells Docker to stop the container named ‘portainer’. You should replace ‘portainer’ with the name of your Portainer container if it’s different.

Removing the Current Portainer Container

After stopping the Portainer container, the next step is to remove it. This is necessary because Docker needs to remove the old container before it can replace it with the new one.

Using the Docker Remove Command

In the terminal window, type the following command:

docker rm portainer

This command tells Docker to remove the container named ‘portainer’. As before, replace ‘portainer’ with the name of your Portainer container if it’s different.

Pulling the Latest Portainer Image

With the old Portainer container removed, you can now pull the latest Portainer image from the Docker repository.

Using the Docker Pull Command

In the terminal window, type the following command:

docker pull portainer/portainer-ce

This command tells Docker to pull the latest image for the Community Edition of Portainer from the Docker repository.

Running the New Portainer Container

After pulling the latest Portainer image, you can run the new Portainer container.

Using the Docker Run Command

In the terminal window, type the following command:

docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

This command tells Docker to run a new container with the following specifications:

  • The container should run in detached mode (-d).
  • The container should map port 8000 and 9000 on the host to port 8000 and 9000 on the container.
  • The container should be named ‘portainer’.
  • The container should restart automatically if it stops (–restart=always).
  • The container should mount the Docker socket and the Portainer data volume.
  • The container should use the ‘portainer/portainer-ce’ image.

Verifying the Update

After running the new Portainer container, it’s important to verify that the update was successful.

Checking the Portainer Version

Log back into your Portainer dashboard and navigate to the ‘About’ section. The version number displayed here should be the latest version, confirming that the update was successful.

Updating Other Containers Using Portainer

Portainer isn’t just for managing itself – it can also be used to update other Docker containers.

Using the Recreate Feature

To update another container, navigate to the container in the Portainer dashboard and click on the ‘Recreate’ button. Ensure that the ‘Pull latest image’ option is selected, then click ‘Recreate’ again. Portainer will pull the latest image for the container and replace the current container with a new one using the latest image.

Cleaning Up Unused Images

After updating your containers, it’s a good idea to clean up any unused images to save space.

Removing Unused Images

In the Portainer dashboard, navigate to the ‘Images’ section. Here, you’ll see a list of all the Docker images on your host. Unused images will be marked as ‘unused’. To remove an unused image, select the checkbox next to the image and click the ‘Remove’ button.

Remember, regular updates are an essential part of maintaining a secure and efficient Docker environment. Make sure to regularly check for and apply updates to keep your Docker containers, including Portainer, up to date.

Similar Posts