致敬 @遇见狂神说
自学课程地址:https://www.bilibili.com/video/BV1og4y1q7M4?p=1
以下为根据课程记录的笔记,可以作为参考但是建议,自己记录安装系统:CentOS
Docker的常用命令
帮助命令
docker version #显示docker的版本信息
docker info #显示docker的系统信息,包括镜像的容器和数量
docker --help #帮助命令
帮助文档地址:https://docs.docker.com/engine/reference/commandline/
镜像命令
docker images 查看所有本地的主机上的镜像
[root@coder ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 3 months ago 13.3kB
# 解释
REPOSITORY 镜像的仓库源
TAG 镜像的标签
IMAGE ID 镜像的id
CREATED 镜像的创建时间
SIZE 镜像的大小
#可选项
-a, --all # 列出所有的镜像
-q, --quiet # 只显示镜像的ID
docker search 搜索镜像
[root@coder ~]# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11912 [OK]
mariadb MariaDB Server is a high performing open sou… 4558 [OK]
# 可选项,通过收藏来过滤
--filter=STARS=3000 # 搜索出来的镜像就是STARS大于3000的
[root@coder ~]# docker search mysql --filter=STARS=3000
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11912 [OK]
mariadb MariaDB Server is a high performing open sou… 4558 [OK]
docker pull 下载镜像
# 下载镜像 docker pull 镜像名[:tag]
[root@coder ~]# docker pull mysql
Using default tag: latest #如果不写tag,默认就是latest
latest: Pulling from library/mysql
72a69066d2fe: Pull complete #分层下载,docker images 的核心 联合文件系统
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
docker pull docker.io/library/mysql:latest
docker rmi 删除镜像
[root@coder ~]# docker rmi -f 镜像id # 删除指定的镜像id
[root@coder ~]# docker rmi -f 镜像id 镜像id 镜像id # 删除多个镜像
[root@coder ~]# docker rmi -f $(docker images -aq) # 删除全部的镜像