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:
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:
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>
.
Portainer also runs as a container. The setup is described here. You can make a backup of your data first if you want.
-
Go to
Containers
-
Open the container by clicking on the container name
-
Stop the container
-
Rename the container
ClickEdit
, this is a button after the name of the container. Type.save
after the name of the container -
Click
Duplicate/Edit
-
Now remove
.save
from the name of the container -
Click
Deploy the container
The containers with .save
in the name and the associated images can be deleted at a later time if the new container is running properly.
No comments found for this note.
Join the discussion for this note on Github. Comments appear on this page instantly.