Docker 常用命令
帮助文档:https://docs.docker.com/engine/reference/commandline
docker 镜像命令
#查看docker的版本
docker version
#
#帮助命令
docker --help
#查看镜像
docker images
REPOSITORY 镜像仓库源
TAG 镜像标签
IMAGE ID 镜像ID
CREATED 镜像的创建时间
SIZE 镜像的大小
REPOSITORY TAG IMAGE ID CREATED SIZE
gitlab/gitlab-ce latest 46cd6954564a 3 months ago 2.36GB
jenkins/jenkins latest 55860ee0cd73 3 months ago 442MB
felicia/centos 1.0 df29f8034db4 4 months ago 231MB
tomcat_felicia 01 3069d9a1cbc7 4 months ago 684MB
docker latest ff1c1f4454a0 4 months ago 216MB
可选项
-a 显示所有镜像 docker images -a
-q 只显示显示镜像的id docker images -q
docker search 搜索镜像
#搜索mysql 镜像
docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 12407 [OK]
mariadb MariaDB Server is a high performing open sou… 4780 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Create… 918 [OK]
percona Percona Server is a fork of the MySQL relati… 574 [OK]
phpmyadmin phpMyAdmin - A web interface for MySQL and M… 501 [OK]
#可选项,可以过滤
-f --filter
docker search mysql -f=STARS=4780 #过滤STARS>4780
docker pull 拉取镜像
#下载镜像 docker pull 镜像名[:tag]
[root@iZwz9f559fa6a275jj2x0sZ ~]# docker pull mysql #如果不写tag,默认就是latest
Using default tag: latest
latest: Pulling from library/mysql
72a69066d2fe: Pull complete #分层下载
93619dbc5b36: Pull complete
99da31dd6142: Pull complete
626033c43d70: Pull complete
37d5d7efb64e: Pull complete
ac563158d721: Pull complete
d2ba16033dad: Pull complete
688ba7d5c01a: Pull complete
00e060b6d11d: Pull complete
1c04857f594f: Pull complete
4d7cfa90e6ea: Pull complete
e0431212d27d: Pull complete
Digest: sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709 #签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest #真实地址
#指定版本下载
docker pull mysql:5.7 #版本一定要在hub docker 存在
docker rmi 删除镜像 rm 就是Linux 的删除 i 是images
#删除指定镜像
docker rmi -f 镜像id
#删除多个镜像
docker rmi -f 镜像id 镜像id
#删除所有镜像
docker rmi -f $(docker images -aq)
查看镜像的详细信息
docker image inspect 镜像名称:版本号
查看镜像的创建历史
docker history 镜像id
[root@iZwz9f559fa6a275jj2x0sZ usr]# docker history 3218b38490ce
IMAGE CREATED CREATED BY SIZE COMMENT
3218b38490ce 4 months ago /bin/sh -c #(nop) CMD ["mysqld"] 0B
<missing> 4 months ago /bin/sh -c #(nop) EXPOSE 3306 33060 0B
<missing> 4 months ago /bin/sh -c #(nop) ENTRYPOINT ["docker-entry… 0B
<missing> 4 months ago /bin/sh -c ln -s usr/local/bin/docker-entryp… 34B
<missing> 4 months ago /bin/sh -c #(nop) COPY file:345a22fe55d3e678… 14.5kB
<missing> 4 months ago /bin/sh -c #(nop) COPY dir:2e040acc386ebd23b… 1.12kB
本文介绍了Docker的常用命令,包括查看版本、搜索镜像、拉取与删除镜像,以及查看镜像详情和历史。通过实例演示了如何使用docker search、docker pull、docker rmi等命令,帮助读者掌握Docker的基本操作。
38万+

被折叠的 条评论
为什么被折叠?



