Skip to content

How to update Docker containers

Introduction

In recent years, I have used various methods to update Docker containers when a new image was available.

How To

Below are the methods for the Linux terminal and Portainer.

As an example I’m using the portainer/portainer-ce image. Run the following command to download the image:

# Open your terminal application
sudo docker pull portainer/portainer-ce

Continue when a new image is downloaded else there is no update. As an example I’m using my Portainer container setup. You can make a backup of your data first if you want. Run the following commands:

# Open your terminal application
sudo docker stop portainer
sudo docker rename portainer portainer.save

Now create the container again with the new image. In this case you need to run the portainer_run.sh shell script. The data is retained due to the volumes we have set in the script.

The container with .save in the name can be deleted with docker rm portainer.save at a later time if the new container is running properly.Remaining images can be cleaned with docker image prune or view the images and the id of the images with docker images -a and delete a single image with docker rmi <id>.

Favorites

Comments

    No comments found for this note.

    Join the discussion for this note on Github. Comments appear on this page instantly.

    Copyright 2021- Fiction Becomes Fact