1, Docker's three components of the image.
Docker needs to have a corresponding mirror locally before running the container, and if the mirror does not exist locally, Docker will download it from the Mirror repository (by default
The repository in the Docker Hub Public Registry server). Get mirroring from the repository, manage mirroring on the local host, and describe the fundamentals of the mirroring implementation. 1.1 Getting mirrored docker pull instructions
We downloaded an Ubuntu 12.04 operating system image from the Docker Hub repository.
#上一篇博客有说到, get a mirror.
[root@bfd-v7 ~]# Docker Pull ubuntu:12.04
1.2 List all mirrors, docker images instructions
Docker images
In the listing information, you can see several field information: which warehouse, such as the Ubuntu image tag, such as 14.04 its ID number (unique) Create time mirror size 1.3 Create mirror
There are many ways to create an image, and users can obtain an existing image from the Docker Hub and update it, or they can use the local file system to create a
A. 1.3.1, a new Wyl-nginx image is generated based on the existing nginx image.
Docker CP index.html 5cbfdbbe064b://usr/share/nginx/html
Docker commit-m "Fun" 5cbfdbbe064b Wyl-nginx
The previous Nginx image is the Nginx Welcome page after the run of the page, we make a change to the previous one, then run, then a new image will be generated.
1.3.2, dockerfile image Generation
#创建一个dl目录dockerfile的缩写
[root@bfd-v7/]# mkdir DL
[root@bfd-v7 dl]# cd DL
[root@bfd-v7 dl]# Touch Dockerfile
[root@bfd-v7 dl]# vim Dockerfile
#写上下面的呃逆荣 from
alpine:latest
maintainer wyl9527
CMD echo "Hello Docker
Dockerfile Basic syntax is: Use # to annotate the from instruction to tell Docker which image to use as the basis followed by the maintainer's information CMD run instructions
[Root@bfd-v7 dl]# Docker build-t Hello-docker.
Where the-t flag is added to the tag to specify the user information for the new mirror. "." is the path (current directory) where the Dockerfile is located, or it can be replaced by a specific Dockerfile path.
You can see that the build process is performing an action. The first thing it needs to do is upload this Dockerfile content, because all the operations are based on Dockerfile. Then, the instructions in the dockfile are executed by one line. Each step creates a new container, executes the instructions in the container, and submits the changes (as in the case of the Docker commit described earlier). When all instructions have been executed, the final mirror ID is returned. All the containers produced by the intermediate steps are deleted and cleaned up.
* Note that an image cannot exceed 127 levels 1.4 Image Export and import 1.4.1, if you want to export the image to a local file, you can use the Docker Save command.
[Root@bfd-v7 ~]# Docker save-o wyl-nginx.tar.gz wyl-nginx
[root@bfd-v7 ~]# Docker save-o hello-docker.tar.gz hello-d Ocker
Export to the current directory, as shown in the Hello-docker.tar.gz file in the following figure.
1.4.2 can be imported from the exported local file to the local mirror library using Docker load
Use Docker rm to delete all containers that depend on this image before deleting the image.
Since we have already had the image of Hello-docker, we will first delete and then import.
[Root@bfd-v7 ~]# Docker rmi Hello-docker
#出现下面的错误
[Root@bfd-v7 ~]# Docker load
1.5 removing local mirrors
If you want to remove a local mirror, you can use the Docker RMI command. Note that the Docker RM command removes the container or an error occurs.
[root@bfd-v7 ~]# Docker RM container ID #上面的截图中有看到操作过程. [Root@bfd-v7 ~]# Docker RMI Hello-docker