1. 显示版本信息
docker version
docker info
docker 命令 --help
2. 帮助文档
https://docs.docker.com/reference/
3. 镜像命令
(1)查看本地主机上的所有镜像
docker images
?例如:
[root@192 /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 5d0da3dc9764 5 days ago 231MB
mysql 5.7 1d7aba917169 2 weeks ago 448MB
mysql latest 0716d6ebcc1a 2 weeks ago 514MB
hello-world latest d1165f221234 6 months ago 13.3kB
[root@192 /]#
可选项:
--all , -a Show all images (default hides intermediate images)
--digests Show digests
--filter , -f Filter output based on conditions provided
--format Pretty-print images using a Go template
--no-trunc Don't truncate output
--quiet , -q Only show image IDs
(2)搜索镜像
docker search 容器名
?可选项:
[root@192 /]# docker search --help
Usage: docker search [OPTIONS] TERM
Search the Docker Hub for images
Options:
-f, --filter filter Filter output based on conditions provided
--format string Pretty-print search using a Go template
--limit int Max number of search results (default 25)
--no-trunc Don't truncate output
例如,搜索mysql的镜像
[root@192 /]# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11439 [OK]
mariadb MariaDB Server is a high performing open sou… 4343 [OK]
例如,根据条件搜索:
[root@192 /]# docker search mysql --filter=STARS=5000
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11439 [OK]
[root@192 /]#
(3)下载镜像
docker pull 镜像名[:tag]
例如,下载最新版本mysql镜像:
[root@192 /]# docker pull mysql
例如,下载某一版本mysql镜像:
[root@192 /]# docker pull mysql:5.7
(4)删除镜像
删除某一镜像
docker rmi -f 容器id
例如:
[root@192 /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 5d0da3dc9764 5 days ago 231MB
mysql 5.7 1d7aba917169 2 weeks ago 448MB
mysql latest 0716d6ebcc1a 2 weeks ago 514MB
hello-world latest d1165f221234 6 months ago 13.3kB
[root@192 /]# docker rmi -f 1d7aba917169
Untagged: mysql:5.7
Untagged: mysql@sha256:d9b934cdf6826629f8d02ea01f28b2c4ddb1ae27c32664b14867324b3e5e1291
Deleted: sha256:1d7aba9171693947d53f474014821972bf25d72b7d143ce4af4c8d8484623417
Deleted: sha256:94ebbead5c58282fef91cc7d0fb56e4006a72434b4a6ae2cd5be98f369cb8c21
Deleted: sha256:989da5efad29ec59bd536cd393d277bc777f8b9b34b8e3ad9593a4b0a83b40f4
Deleted: sha256:7457ee6817c678da3cb383d27a3d79d5f3f25fbcb92958d5e8d5709e7631e23c
Deleted: sha256:fe7dac53adebe33519b4e4fc577bfcddd7372cc313c35fae681fc82fb325fdc0
[root@192 /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 5d0da3dc9764 5 days ago 231MB
mysql latest 0716d6ebcc1a 2 weeks ago 514MB
hello-world latest d1165f221234 6 months ago 13.3kB
[root@192 /]#
删除全部镜像
docker rmi -f $(docker images -aq)
例如:?
[root@192 /]# docker rmi -f $(docker images -aq)
Untagged: mysql:latest
Untagged: mysql@sha256:99e0989e7e3797cfbdb8d51a19d32c8d286dd8862794d01a547651a896bcf00c
Deleted: sha256:0716d6ebcc1a61c5a296fcb187e71f93531e510d4e4400267e2e502103d0194c
Deleted: sha256:dc895a08d34b5b81fc4ca087d2ad52cbe1a2050e249040a22c5f2eabf2f384ba
Deleted: sha256:660229dcf1a452460127a498b9f3f161e7ca94507353ded8af92fe9ab55a32ed
Deleted: sha256:6b26fa2fc4e2150aee2f2557bcbfaf727c00d1650ea08d8ed3fe7c8a6caaa88b
Deleted: sha256:c20303553d5d2594e1655000089b12eca8db7afdcb068cc35fc47ebfe3dab5fb
Deleted: sha256:77a3d69619bfea7b30831a41a32bbf61756c9f95513743deea8daa9a83ff2646
Deleted: sha256:9578f1c7f00f400b3f71be0ee721cbc0892e05e454323e1a74a6e56ae1dafdab
Deleted: sha256:335f9f9fbbd8977530806ed5439a2b67f1c06117f752a2598698de4ae304c516
Deleted: sha256:e15ed274d47a7d6ddff0afcc628143254c69128a9d2379900ebb519e7c6c2bce
Deleted: sha256:51930b767631b583738d75519bed2a8cc757c5b0c904617972386462deee2ca7
Deleted: sha256:43bd682fb659113a8ab168032d8f82dee86d2cee5cee2e146af6c3a6f9ccef18
Deleted: sha256:1957f1873568b423369e0299de6c9b75a111fea807b0c07506ba45d075ca8f80
Deleted: sha256:d000633a56813933cb0ac5ee3246cf7a4c0205db6290018a169d7cb096581046
Untagged: hello-world:latest
Untagged: hello-world@sha256:7d91b69e04a9029b99f3585aaaccae2baa80bcf318f4a5d2165a9898cd2dc0a1
Deleted: sha256:d1165f2212346b2bab48cb01c1e39ee8ad1be46b87873d9ca7a4e434980a7726
Error response from daemon: conflict: unable to delete 5d0da3dc9764 (cannot be forced) - image is being used by running container 129ae722b6a4
[root@192 /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos latest 5d0da3dc9764 5 days ago 231MB
[root@192 /]#
|