docker-docker mirror "docker combat chapter" created using the python command (32)

He said last time after the image is downloaded to the local docker appium by docker run command appium port, and start the application in the night vibrato God simulator through a python script, did not say before making docker mirror, if you want to customize how to customize your own docker mirror.

The method of making mirror docker

Mirroring is the basis of the container, when the container is running, will specify that the mirror is the base of the container running in the previous example, the use of a mirror is dockerHub inside mirror, direct use of these images are certain to meet our needs, when these images can not meet the demand, we will need to customize the image. Mirroring is layered, multi-layered stored for each layer is modified on the basis of the previous layer, the multilayer container is also stored, as the mirror base layer formed in the container base image running on storage layer.

  • commit the ways mirrored
    1. Download the base image nginx

 docker run --name webnginx -d -p 80:80 nginx

2. Check container

Access browser: http: //192.168.70.100

3. Modify the default page of text

 docker exec -it webnginx bash
# After entering the vessel to modify the default page
echo "<h1>welcome to idig8.com study docker</h1>" > /usr/share/nginx/html/index.html

4. View modified records

View the last change

docker diff webnginx

5.docker commit command

docker commit [Option] <container or containers ID name> [<repository name> [: <label>]]

docker commit --author "idig8<idig8.com>" --message "Modify default page" webnginx nginx:v1

docker images

6.docker 镜像历史

docker history nginx:v1

7.使用定制镜像生成容器

指定一个81端口的服务,发现是按照之前打包容器的镜像,生成的容器。

docker run --name webnginx2 -d -p 81:80 nginx:v1


8.慎用docker commit命令生成镜像

虽然可以比较直观的帮助理解镜像分层存储的概念,但是实际环境中并不会这样使用。犹豫命令的执行,还有很多文件被改动或添加。这还仅仅是最简单的操作,如果是安装软件包,编译构建,那会有大量的无关内容被添加进来,如果不小心清理,将会导致镜像极为臃肿。此外,使用docker commit意外这所有对镜像的操作都是黑箱操作,生成的镜像也被称为黑箱镜像。实际工作中尽量不使用这个。

  • dockerfile的方式制作镜像
    >下次说。

PS:到此第一次完成了镜像的定制。使用的命令就是docker commit,手动操作给旧的镜像添加了一个新的层形成了一个新的镜像,大家对镜像多层分组应该有了感觉。



Guess you like

Origin blog.51cto.com/12040702/2417564