Analysis of Docker's method for creating local images

Analysis of Docker's method for creating local images

The so-called container actually creates a readable and writable file hierarchy based on the parent image. All modification operations are performed on this file hierarchy, and the parent image is not affected. If the reader needs to create a new local image based on this modification, there are two different ways. This article first looks at the first way: commit.

Create a container

First, run a container based on the local image as follows:


Command Explanation:

  • First, execute the docker images command to view the local image.
  • Create a container named nginx based on the nginx image in the local image and start it.
  • Copy a file named index.html from the host to the container.
  • Access the container and find that the changes have taken effect.
  • Next, create a new container named nginx2.
  • When accessing nginx2, I found that the default page in nginx2 was still the default page of nginx and had not changed.

Create a local image

Next, create a local image based on the first container just created, as follows:


Command Explanation:

  • The parameter -m is a brief description of the created image.
  • --author indicates the author of the image.
  • ce1fe32739402 indicates the ID of the container on which the image is created.
  • sang/nginx indicates the warehouse name, sang is the namespace, and nginx is the image name.
  • v1 indicates the tag of the repository.
  • After the creation is complete, you can view the image you just created through the docker images command.
  • Run a container through the image you just created and access the container. You will find that the default homepage of nginx has changed.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • .NETCore Docker implements containerization and private image repository management
  • Docker private repository management and deletion of images in local repositories
  • Briefly describe how to install Tomcat image and deploy web project in Docker
  • The simplest implementation of spring boot packaging docker image
  • How to generate a docker image and complete container deployment in a spring boot project
  • How to deploy Vue project using Docker image + nginx
  • Detailed explanation of the latest IDEA process of quickly deploying and running Docker images
  • Detailed explanation of the use of DockerHub image repository
  • Docker image management common operation code examples

<<:  el-table in vue realizes automatic ceiling effect (supports fixed)

>>:  Detailed tutorial on installing mysql8.0.22 on Alibaba Cloud centos7

Recommend

Disadvantages and reasonable use of MySQL database index

Table of contents Proper use of indexes 1. Disadv...

How to use crontab to backup MySQL database regularly in Linux system

Use the system crontab to execute backup files re...

Mobile terminal adaptation makes px automatically converted to rem

Install postcss-pxtorem first: npm install postcs...

Introduction to HTML link anchor tags and their role in SEO

The <a> tag is mainly used to define links ...

How to use Xtrabackup to back up and restore MySQL

Table of contents 1. Backup 1.1 Fully prepared 1....

Vue page monitoring user preview time function implementation code

A recent business involves such a requirement tha...

The pitfall of MySQL numeric type auto-increment

When designing table structures, numeric types ar...

Detailed example of jQuery's chain programming style

The implementation principle of chain programming...

Analyze how a SQL query statement is executed in MySQL

Table of contents 1. Overview of MySQL Logical Ar...

Detailed steps to configure my.ini for mysql5.7 and above

There is no data directory, my-default.ini and my...

How to find slow SQL statements in MySQL

How to find slow SQL statements in MySQL? This ma...