How to update Docker image to maintain your containers secure
In a Docker infrastructure, the Docker containers are created using images. Containers are instances that are created when the image files are executed. These images can be of web servers, mail servers, applications, and so on.
Docker images are stored in locations knows as repository or registry. There are two types of repository – public registry (Docker hub maintained by Docker) and private repository (maintained by Docker users).
Many often, businesses require to customize these Docker images to suit their specific purposes. Here, we’ll discuss how to update Docker images for your containers.
When to update Docker images?
Container images are usually updated during these scenarios:
- To obtain the latest version of a software or application release
- To add or modify features in the existing software
- To patch and protect software or service from security vulnerabilities
- To customize existing images for specific requirements
In all these situations, the existing container images have to be updated and used in the Docker containers. This process is usually referred to as ‘building’ Docker images.
Images can be built in two ways – 1. By manually executing the steps such as downloading, customizing and committing the images. 2. Using a Docker file.
We’ll see both the methods here:
Get images for Docker from the repository
When you manually build an image through the interactive command-line session, the first step is to get the required image from the repository it is stored in – either the DockerHub or private repository.
The images in the Docker hub are maintained by Docker and they would update it periodically. But maintaining the images in the private repository is the responsibility of each business owner.
Once you have identified the required image in the repository, using ‘docker search‘ command, you can download it from the Docker repository using ‘docker pull‘ command:
docker pull ubuntu
With these downloaded images, Docker containers can be created. The list of images in your Docker host can be identified using ‘docker images’ command.
Maintaining and updating the images in the local repository is a crucial aspect, as there are chances these images get prone to security vulnerabilities or hacks otherwise.
[ Are your spending too much time managing your Docker containers? Our Docker experts take care of your infrastructure and ensure its smooth functioning. ]