Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Docker command

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

1. Mirror IMAGES operation class

1. Image renaming

Docker tag IMAGE ID NEW REPOSITORY:NEW TAG

IMAGE ID indicates the existing image ID number, and NEW REPOSITORY:NEW TAG indicates the need for a new image name and label, as follows:

Or

Docker tag OLD REPOSITORY NEW REPOSITORY:NEW TAG

OLD REPOSITORY represents the original old image name

But note: docker renames the image, not really renaming it, but renaming the original image copy. The old image still exists.

2.docker uses commit to build a new image based on an existing image

Create a container with and stop running:

Docker run-itd-- name: / bin/bash

Docker stop

Build a new image based on the stopped container:

Docker:

For example:

Docker run-itd-- name ng nginx:latest / bin/bash

Docker stop ng

Docker 912d22c4d37e | ng 20190408_ngnix:20190408_latest

The principle of the construction process:

After creating a running container based on the existing basic image, while the container writes the content it needs, docker will copy the original image layer from top to bottom, and add a read-write layer (the content you need is written on the read-write layer), which is called "copy on write".

Then package the container commit into a new image, create and run a container with the new image, and the original read-write layer becomes a read-only layer.

2. Container operation

1. Run the container command to explain

Docker run-it-d-name ng nginx:latest / bin/bash

/ bin/bash: refers to the command that runs in the container, rather than specifying the bash interpreter on the host

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report