22/05/2021
Docker
upgrade
Cloud

Sometimes I must upgrade my local docker images from a public repo. The best way to update an existing container with the newest image is to download the latest image and launch a new container with the same configuration. Follow the steps listed below to update your container with the newest Docker image.

# Check Current Version

Verify you have an outdated image, by listing the images on your system with the command:

sudo docker images

The output displays downloaded images and their tags (the tag will given mostly the latest version number. In this example below I use the tag latest.

# Pull the Latest Image

Now you must first download the newer version of the image using the docker pull command:

docker pull buanet/iobroker:latest

By default, Docker pulls the latest version. To ensure it does so, you can add the :latest tag.

# Launch a New Updated Container

Once you downloaded the latest Docker image, you need to stop and remove the old container. Then, create a new one with the latest image.

  1. Find the name of the running container with the outdated image by listing the containers on the system:
docker ps

in this output I will se my known Image. So now I pick the Container ID to stop and remove the container.

  1. Stop and remove the existing container so you can launch a new one under the same name:
docker stop [container_id]
docker rm [container_id]
  1. Recreate the container with the docker run command and the wanted configuration, using the updated Docker image:
docker run --name=[container_name] [options] [docker_image]

This is a small run command. Sure you can now use your own run command for now. To attach the mount volumens and so on. I prefer for my home server docker-compose, because it's simple to use and has now overhead for me.

  1. You can check whether your container has been updated with the latest Docker image by listing the containers with:

# Conclusion

With this handy howto you have updates your docker images very quickly.

👋 Hi ich bin's, Sascha