How to update Docker image to maintain your containers secure__docker

Source: Internet
Author: User
Tags web hosting docker hub docker run

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 is 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 B Y docker users).

Many often, businesses require to customize this Docker images to suit their. 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 Ease to add or modify features in the existing software to patch and protect software or service out of security Vulnerabili Ties to customize existing images for specific requirements

In all these situations, the existing container images have updated and used in the Docker. This process was 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 be both the methods here: Get images for Docker from the repository

When you are manually build a image through the interactive command-line session, the ' The ' the ' I ' 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 update it would. But maintaining the images in the private repository are 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, the Docker containers can be created. The list of images in your Docker host can is identified using ' Docker images ' command.

List Docker Images

Maintaining and updating the images in the local repository are a crucial aspect, as there are chances these images get pro NE to security vulnerabilities or hacks otherwise.


Update the Docker image

Once the "image is" downloaded into the host machine, "Next step" to update a particular Docker image are to create a Conta Iner using it.

Then the required modifications can be done in the container and that image can is copied over. Here are the "steps": 1. Create A new container

The all, create the container using the Docker image of your want to modify. The command is:

Docker Run-t-I. Ubuntu/bin/bash
2. Make the required changes

Access the new container and make to the updates or modifications needed in it. It could be actions such as applying security patches, modifying the application code, recompiling the service with new MO Dules, and so on. 3. Exit the container

After making the modifications and updates, exit the container. 4. Commit the changes

Once the container is updated, commits the changes made in this container to a Docker image using ' Docker commit '.

Docker commit-m "Changes made" [Container-id] Ubuntu:v2

This new image would now is listed in the Docker host and it can is used to create new containers. 5. Push The new image to the repository

The updated Docker image can be added to the Docker repository using ' Docker push '. Obsolete images can be removed from the repository to avoid from being used.

[Running a Docker infrastructure doesn ' t have to be hard, or costly. Get world class Docker management services at affordable pricing. ] Update docker images using Dockerfile

To simplify this Docker image update steps, there is another way the using ' Docker build ' command. It builds a container with the help of a dockerfile.

A dockerfile contains a set of instructions that can is used to update the container image. For instance, to configure PHP in a container, a sample file is:

Customer Dockerfile to create containers

The from directive says what the base image should is. The RUN command installs the necessary packages from Ubuntu repository, and the ADD command copies the contents of ' t mp/mageshop01/html/' to '/var/www/html ' folder of the server instance.

You can does further customization on the PHP and Apache configuration files using the more RUN commands in the dockerfile. Once the "Dockerfile is updated," use the "command to" build "the new image using this file:

Docker build-t ubuntu:v2 ' Path-to-docker-file '

Using the given Docker file, the ' Docker build ' command would create a container with the updated image. The new image name can be set using the '-t ' option. This image can is ' pushed ' to the repository for future use.

We ' ve been able to prevent server incidents by the up to 15% by using our proactive server checks (click here to "how we IM Prove web hosting support).

[Use your time to build your business. We ' ll take care of your customers. Hire Our Docker Support specialists at affordable pricing. ] In short ..

Today we saw you to update containers with the modified or new Docker images. Setting tags on this images helps to identify them easily for future use.

Care has to is exercised in maintaining the images in the Docker repository and secure. Any custom configuration do should be preserved as is, with version control.

Whenever a vulnerability is reported, immediate patching of the "image has to being done." At Bobcares, we 24/7 security team manages these images up-to-date.

Original address: Https://bobcares.com/blog/update-docker-image

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.