With our several articles Docker command learning, command learning about Docker local image management is nearing the end. Today we will look at the last three commands for local image management: history,save, and import. Of course, if you are not familiar with the previous commands, you can review the previous commands and learn the knowledge in this chapter. Docker learning series 1 Docker learning series 2 Docker learning series 3 ~ command learning Docker learning series 4 ~ source modification to increase efficiency then now start our command learning now

history

The docker history command is used to view the creation history of a specified image.

Docker history [OPTIONS] image

OPTION is still optional as before:

  • -h: prints the image size and date in a readable format. The default value is true
  • –no-runc: displays the commit record
  • -q: lists the ids of the submitted records. The following is an example:
docker@ubuntu:~$ docker history mongo
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
8bf72137439e        8 days ago          /bin/sh -c #(nop) CMD ["mongod"] 0B
<missing>           8 days ago          /bin/sh -c #(nop) EXPOSE 27017/tcp 0B
<missing>           8 days ago          /bin/sh -c # (nop) ENTRYPOINT [" docker - entry... 0 b
<missing>           8 days ago          /bin/sh -c # (nop) COPY file: 18 c5d9b642a89adf... 10.4 kB
<missing>           8 days ago          /bin/sh -c #(nop) VOLUME [/data/db /data/co... 0B<missing> 8 days ago /bin/sh -c mkdir -p /data/db /data/configdb... <missing> 8 days ago /bin/sh -c mkdir -p /data/db /data/configdb... 0B <missing> 8 days ago /bin/sh -cset-x && apt-get update && apt... 256MB <missing> 8 days ago /bin/sh -cecho "deb http://$MONGO_REPO/ apt /... 73B < MONGO_VERSION /bin/sh -c #(nop) ENV MONGO_VERSION= 5.0.1b < MONGO_VERSION /bin/sh -c #(nop) ENV MONGO_MAJOR= MONGO_MAJOR <missing> 2 weeks ago /bin/sh -c #(nop) ENV MONGO_PACKAGE= mongo_mongodb... 0B <missing> 2 weeks ago /bin/sh -c #(nop) ARG MONGO_REPO=repo.mongo... 0B < MONGO_PACKAGE > 2 weeks ago /bin/sh -c #(nop) ARG MONGO_PACKAGE=mongodb... 0B docker@ubuntu:~$ docker history -q mongo 8bf72137439e <missing> <missing> <missing> <missing> <missing>Copy the code

save

Docker Save is the value to save the specified image as a tar archive. We can forward docker files to others to use directly.

Syntax sugar docker save [OPTIONS] IMAGE[] array

The OPTIONS:

  • -o: indicates the output file

Example:

docker@ubuntu:~$ docker save -o mongo.tar mongo
docker@ubuntu:~$ ls
Desktop    Downloads         mongo.tar  Pictures  Templates
Documents  examples.desktop  Music      Public    Videos
Copy the code

import

We just used the save command above to archive the docker file, so if we get the archive tar file, how do we restore the docker file? Now we can use the import command

Docker import [OPTIONS] file[URL] [REPOSITORY:TAG]

OPTIONS:

  • -c: Apply the Docker command to create an image
  • -m: description of submission

Example:

docker@ubuntu:~$ docker import mongo.tar mong:v1 sha256:9a611936a0107c2f07e04ea586722dba2b6c6451c3f1ae68fda30496b91c606e  docker@ubuntu:~$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE mong v1 9a611936a010 26 seconds ago 386MB mongo 13.8BF72137439e 8 days ago 380MB Mongo latest 8BF72137439e 8 days ago 380MBCopy the code

We can see that there is a new mONG with a TAG of V1. That’s what we added.

conclusion

From the command above we can see that these local mirror commands are related, used to help us operate the docker information. The local mirror management commands are done for today. Next time we’ll look at something else. After learning this chapter, we can review what we have learned before and make a review and summary. Docker learning series 1 Docker learning series 2 Docker learning series 3 ~ command learning container Docker learning series 4 ~ source modification to increase efficiency