I. Overview
There are two ways to create a mirror, one with the commit command, and the second with the Dockerfile method (which is more commonly described in the following article). This chapter describes the commit method.
Before we introduce the commit command, we review the versioning of the code, and when we change the code, we commit to the version server.
For a container-like concept, the commit command can be used to commit the modification to a new image once the container has been created, if the container has been modified later.
Ii. Illustrative examples
Let's take a concrete example to illustrate:
1. Create a new container
Docker run--name newcontent-i-T Ubuntu/bin/bash
2, to operate, modify the contents of the container
echo Hello World >>test.txt//Create a file with the redirect feature
3. Exit the shell and close the container.
4. Use the diff command to view container change information
Diff//root//test.txt
5. Create a new image
Docker commit Newcontent Newnewcontent2
A mirror is created locally that has a warehouse named Newnewcontent2,tag with the default value of latest.
The image name for the specification should be:
[Username/]repositoryname[:tagname]
such as: Docker commit newcontent jeme/myubuntu:1.0
If there is no tagname, the default is latest.
Note: If you need to submit the image to the Dokcer hub hub, you must standardize the naming (must be username/warehouse name, tag can default), and the previous user name is the username registered on the Dokcer hub.
Third, delete the local mirror
Docker RMI Image name/id
Docker Learning Note 5: Creating a mirror with the commit command and deleting a local mirror