Get the App
SLTechnology News&Howtos  ›  Servers  › 

Docker Image Management and acceleration site

Shulou Source: shulou.com Published: 2022-06-03 05:08:59 10月16日 Update

I. concept

To put it simply, an image is a concrete packaged container environment, which does not include a kernel but a compact operating system.

Configure the image acceleration site

When we are in pull Image, docker is downloaded from foreign Docker Hub by default, so it will be very slow. Let's solve this problem by configuring domestic acceleration sites.

1. Edit the / etc/docker/daemon.json file and configure it as follows

{

"registry-mirrors": ["http://hub-mirror.c.163.com"]"

}

2. Restart docker

Systemctl restart docker

3. Check whether the configuration is effective.

Using the docker info command, you can see the acceleration site that Registry Mirrors has displayed for our configuration

III. Mirror management

1. Download the image from the image repository

Docker pull nginx

2. View the image

Docker image ls

You can see the nginx image downloaded in step 1

3. Package the image

Package the nginx image and specify that the archive file name is nginx.tar

Docker save nginx > nginx.tar

4. Delete the image

Docker image rm nginx

At this point, we delete the image and then use ls to view it. We can see that there are no images left.

5. Load the image

Docker load

< nginx.tar 使用load命令将第3步打包的镜像加载回去,再使用ls可以看到镜像加载成功 6、使用镜像创建容器 docker run -itd --name nginx1.0 nginx 这里指定容器名为nginx1.0,镜像为nginx 7、将容器打包 4858b7bd6ad8为第6步创建的容器id docker export 4858b7bd6ad8 >

Nginx1.0.tar

8. Create an image using the tar file packaged by the container

Docker image import nginx1.0.tar

Using the ls command to view, we can see that a new image has been created, but both REPOSITORY and tag are empty

We can create the specified REPOSITORY and tag again

Docker image import nginx1.0.tar nginx1.0:v1

9. Mark the image

Docker tag nginx1.0:v1 nginx1.0:v2

A new image is created with a tag of v2

10. View image details

Docker inspect nginx

There is a lot of content in it. Here, only part of it is intercepted. You can see some path information corresponding to the image.

11. View the historical layering of the image

Docke history nginx

You can see the corresponding dockefile command and size of each layer of the mirror.

Tags: Image container configuration command site file management success operating system up and down warehouse creation information content kernel again history size marking file name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Microsoft Shulou Technology Shulou Information MariaDB