2.11. Docker mirroring usage

发布时间 :2025-10-25 12:31:07 UTC      

When running the container, if the image used does not exist locally, docker is automatically downloaded from the docker image repository. By default, it is downloaded from the Docker Hub public image source.

Let’s learn:

  • 1、管理和使用本地 Docker 主机镜像

  • 2、创建镜像

2.11.1. List a list of images

We can use it. docker images To list the images on the local host.

runoob@runoob:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              14.04               90d5884b1ee0        5 days ago          188 MB
php                 5.6                 f40e9e0f10c8        9 days ago          444.8 MB
nginx               latest              6f8d099c3adc        12 days ago         182.7 MB
mysql               5.6                 f2e8d6c772c0        3 weeks ago         324.6 MB
httpd               latest              02ef73cf1bc0        3 weeks ago         194.4 MB
ubuntu              15.10               4e3b13c8a266        4 weeks ago         136.3 MB
hello-world         latest              690ed74de00f        6 months ago        960 B
training/webapp     latest              6fae60ef3446        11 months ago       348.8 MB

Description of each option:

  • REPOSITORY: Represents the warehouse source of the image

  • TAG: Mirrored label

  • IMAGE ID: Mirror ID

  • CREATED: Mirror creation time

  • SIZE: Mirror Siz

There can be multiple TAG in the same warehouse source, which represents different versions of the warehouse source. For example, there are different versions such as 15.10,14.04 in the ubuntu repository source. We use REPOSITORY:TAG to define different images.

所以,我们如果要使用版本为15.10的ubuntu系统镜像来运行容器时,命令如下:

runoob@runoob:~$ docker run -t -i ubuntu:15.10 /bin/bash
root@d77ccb2e5cca:/#

Parameter description:

  • -i Interactive operation

  • -t Terminal.

  • ubuntu:15.10 This refers to starting the container based on the ubuntu version 15.10 image.

  • /bin/bash Put after the image name is the command, here we want to have an interactive Shell, so we use / bin/bash.

If you want to use the ubuntu system image with version 14.04 to run the container, the command is as follows:

runoob@runoob:~$ docker run -t -i ubuntu:14.04 /bin/bash
root@39e968165990:/#

If you do not specify a version tag for the image, for example, if you only use ubuntu,docker, the ubuntu:latest image will be used by default.

2.11.2. Get a new image

Docker automatically downloads the image when we use a non-existent image on the local host. If we want to download the image in advance, we can use the docker pull command to download it.

Crunoob@runoob:~$ docker pull ubuntu:13.10
13.10: Pulling from library/ubuntu
6599cadaf950: Pull complete
23eda618d451: Pull complete
f0be3084efe9: Pull complete
52de432f084b: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:15b79a6654811c8d992ebacdfbd5152fcf3d165e374e264076aa435214a947a3
Status: Downloaded newer image for ubuntu:13.10

After the download is complete, we can directly use this image to run the container.

2.11.3. Find Mirror

We can search for images from Docker Hub. The Docker Hub address is: https://hub.docker.com/

We can also use the docker search command to search for images. For example, we need an image of httpd as our web service. We can search httpd with the docker search command to find the right image for us.

runoob@runoob:~$  docker search httpd

Click on the picture to see the larger picture:

` <../wp-content/uploads/2016/05/423F2A2C-287A-4B03-855E-6A78E125B346.jpg>` __

NAME: Name of the image warehouse source

DESCRIPTION: Description of the mirror image

OFFICIAL: Is it officially released by docker

stars: Similar to star in Github, it means to like and like it.

AUTOMATED: Build automatically.

2.11.4. Drag the mirror image

We decided to use the image of the official version of httpd in the image above and use the command docker pull to download the image.

runoob@runoob:~$ docker pull httpd
Using default tag: latest
latest: Pulling from library/httpd
8b87079b7a06: Pulling fs layer
a3ed95caeb02: Download complete
0d62ec9c6a76: Download complete
a329d50397b9: Download complete
ea7c1f032b5c: Waiting
be44112b72c7: Waiting

After the download is complete, we can use this image.

runoob@runoob:~$ docker run httpd

2.11.5. Delete Mirror

Use of mirror deletion docker rmi Command, for example, we delete the hello-world image:

$ docker rmi hello-world

Image0

2.11.6. Create a mirror

When the image we downloaded from the docker image repository does not meet our needs, we can change the image in the following two ways.

  • 1、从已经创建的容器中更新镜像,并且提交这个镜像

  • 2、使用 Dockerfile 指令来创建一个新的镜像

Update Mirror

Before updating the image, we need to use the image to create a container.

runoob@runoob:~$ docker run -t -i ubuntu:15.10 /bin/bash
root@e218edb10161:/#

Use in the running container apt-get update Command to update.

After completing the operation, type the exit command to exit the container.

At this point, ID is the container of e218edb10161, which is changed according to our requirements. We can submit a copy of the container by commanding docker commit.

runoob@runoob:~$ docker commit -m="has update" -a="runoob" e218edb10161 runoob/ubuntu:v2
sha256:70bf1840fd7c0d2d8ef0a42a817eb29f854c1af8f7c59fc03ac7bdee9545aff8

Description of each parameter:

  • -m: Submitted description information

  • -a: Specify the mirror author

  • e218edb10161: Container ID

  • runoob/ubuntu:v2: Specify the name of the target image to create

We can use it. docker images Command to view our new image runoob/ubuntu:v2 :

runoob@runoob:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
runoob/ubuntu       v2                  70bf1840fd7c        15 seconds ago      158.5 MB
ubuntu              14.04               90d5884b1ee0        5 days ago          188 MB
php                 5.6                 f40e9e0f10c8        9 days ago          444.8 MB
nginx               latest              6f8d099c3adc        12 days ago         182.7 MB
mysql               5.6                 f2e8d6c772c0        3 weeks ago         324.6 MB
httpd               latest              02ef73cf1bc0        3 weeks ago         194.4 MB
ubuntu              15.10               4e3b13c8a266        4 weeks ago         136.3 MB
hello-world         latest              690ed74de00f        6 months ago        960 B
training/webapp     latest              6fae60ef3446        12 months ago       348.8 MB

Use our new mirror image runoob/ubuntu To start a container.

runoob@runoob:~$ docker run -t -i runoob/ubuntu:v2 /bin/bash
root@1a9fbdeb5da3:/#

Build an image

We use orders. docker build To create a new mirror from scratch To do this, we need to create a Dockerfile file that contains a set of instructions to tell Docker how to build our image.

runoob@runoob:~$ cat Dockerfile
FROM    centos:6.7
MAINTAINER      Fisher "fisher@sudops.com"

RUN     /bin/echo 'root:123456' |chpasswd
RUN     useradd runoob
RUN     /bin/echo 'runoob:123456' |chpasswd
RUN     /bin/echo -e "LANG=\"en_US.UTF-8\"" >/etc/default/local
EXPOSE  22
EXPOSE  80
CMD     /usr/sbin/sshd -D

Each instruction creates a new layer on the mirror, and each instruction must be prefixed in uppercase.

The first FROM, which specifies which mirror source to use

The RUN instruction tells docker to execute the command in the image and what is installed.

Then we use the Dockerfile file to build an image through the docker build command.

runoob@runoob:~$ docker build -t runoob/centos:6.7 .
Sending build context to Docker daemon 17.92 kB
Step 1 : FROM centos:6.7
 ---&gt; d95b5ca17cc3
Step 2 : MAINTAINER Fisher "fisher@sudops.com"
 ---&gt; Using cache
 ---&gt; 0c92299c6f03
Step 3 : RUN /bin/echo 'root:123456' |chpasswd
 ---&gt; Using cache
 ---&gt; 0397ce2fbd0a
Step 4 : RUN useradd runoob
......

Parameter description:

  • -t Specify the name of the target image to create

  • . The directory where the Dockerfile file is located, and you can specify the absolute path of Dockerfile

Use docker images to check that the created image already exists in the list, and the image ID is 860c279d2fec.

runoob@runoob:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
runoob/centos       6.7                 860c279d2fec        About a minute ago   190.6 MB
runoob/ubuntu       v2                  70bf1840fd7c        17 hours ago         158.5 MB
ubuntu              14.04               90d5884b1ee0        6 days ago           188 MB
php                 5.6                 f40e9e0f10c8        10 days ago          444.8 MB
nginx               latest              6f8d099c3adc        12 days ago          182.7 MB
mysql               5.6                 f2e8d6c772c0        3 weeks ago          324.6 MB
httpd               latest              02ef73cf1bc0        3 weeks ago          194.4 MB
ubuntu              15.10               4e3b13c8a266        5 weeks ago          136.3 MB
hello-world         latest              690ed74de00f        6 months ago         960 B
centos              6.7                 d95b5ca17cc3        6 months ago         190.6 MB
training/webapp     latest              6fae60ef3446        12 months ago        348.8 MB

We can use the new image to create the container

runoob@runoob:~$ docker run -t -i runoob/centos:6.7  /bin/bash
[root@41c28d18b5fb /]# id runoob
uid=500(runoob) gid=500(runoob) groups=500(runoob)

From the above, we can see that the new image already contains the user runoob we created.

Set image label

We can use the docker tag command to add a new label to the image.

runoob@runoob:~$ docker tag 860c279d2fec runoob/centos:dev

Docker tag image ID, here is 860c279d2fec, user name, image source name (repository name), and new tag signature (tag).

Using the docker images command, you can see that ID is an extra label for the image of 860c279d2fec.

runoob@runoob:~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
runoob/centos       6.7                 860c279d2fec        5 hours ago         190.6 MB
runoob/centos       dev                 860c279d2fec        5 hours ago         190.6 MB
runoob/ubuntu       v2                  70bf1840fd7c        22 hours ago        158.5 MB
ubuntu              14.04               90d5884b1ee0        6 days ago          188 MB
php                 5.6                 f40e9e0f10c8        10 days ago         444.8 MB
nginx               latest              6f8d099c3adc        13 days ago         182.7 MB
mysql               5.6                 f2e8d6c772c0        3 weeks ago         324.6 MB
httpd               latest              02ef73cf1bc0        3 weeks ago         194.4 MB
ubuntu              15.10               4e3b13c8a266        5 weeks ago         136.3 MB
hello-world         latest              690ed74de00f        6 months ago        960 B
centos              6.7                 d95b5ca17cc3        6 months ago        190.6 MB
training/webapp     latest              6fae60ef3446        12 months ago       348.8 MB
Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.