赞
踩
Docker 的常用命令
> docker version #显示docker 版本
> docker info #显示docker的系统信息,包括镜像和容器的数量
> docker #帮助命令
帮助文档的地址: https://docs.docker.com/reference/
镜像命令:
docker images 查看所有本地主机上的镜像
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 11 months ago 13.3kB
#注释:
REPOSITORY 镜像的仓库源
TAG 镜像的标签
IMAGE ID 镜像的ID
CREATED 镜像的创建时间
SIZE 镜像的大小
#可选项
-a , --all #列出所有的镜像
-q , --quiet #只显示镜像的ID
docker search 搜索镜像
[root@localhost /]# docker search mysql NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 10202 [OK] mariadb MariaDB is a community-developed fork of MyS… 3753 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Create… 746 [OK] percona Percona Server is a fork of the MySQL relati… 511 [OK] centos/mysql-57-centos7 MySQL 5.7 SQL database server 86 mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 78 centurylink/mysql Image containing mysql. Optimized to be link… 60 [OK] bitnami/mysql Bitnami MySQL Docker Image 47 [OK] deitch/mysql-backup REPLACED! Please use http://hub.docker.com/r… 41 [OK] #可选项,通过收藏去过滤 --filter=STARS=3000 #搜索出来的镜像STARS大于3000的! [root@localhost /]# docker search mysql --filter=STARS=3000 NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 10202 [OK] mariadb MariaDB is a community-developed fork of MyS… 3753 [OK] --filter=STARS=5000 [root@localhost /]# docker search mysql --filter=STARS=5000 NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 10202 [OK]
docker pull 下载镜像
#下载镜像docker pull 镜像名[:tag] [root@localhost /]# docker pull mysql Using default tag: latest #如果不写tag,默认latest(最后一个版本) latest: Pulling from library/mysql 852e50cd189d: Pull complete #分层下载,docker image的核心,联合文件系统 29969ddb0ffb: Pull complete a43f41a44c48: Pull complete 5cdd802543a3: Pull complete b79b040de953: Pull complete 938c64119969: Pull complete 7689ec51a0d9: Pull complete a880ba7c411f: Pull complete 984f656ec6ca: Pull complete 9f497bce458a: Pull complete b9940f97694b: Pull complete 2f069358dc96: Pull complete Digest: sha256:4bb2e81a40e9d0d59bd8e3dc2ba5e1f2197696f6de39a91e90798dd27299b093 Status: Downloaded newer image for mysql:latest docker.io/library/mysql:latest #真实地址 #等价于它 docker pull mysql docker pull docker.io/library/mysql:latest #指定版本下载: [root@localhost /]# docker pull mysql:5.7 5.7: Pulling from library/mysql 852e50cd189d: Already exists 29969ddb0ffb: Already exists a43f41a44c48: Already exists 5cdd802543a3: Already exists b79b040de953: Already exists 938c64119969: Already exists 7689ec51a0d9: Already exists 36bd6224d58f: Pull complete cab9d3fa4c8c: Pull complete 1b741e1c47de: Pull complete aac9d11987ac: Pull complete Digest: sha256:8e2004f9fe43df06c3030090f593021a5f283d028b5ed5765cc24236c2c4d88e Status: Downloaded newer image for mysql:5.7 docker.io/library/mysql:5.7
docker rmi 删除镜像!
[root@localhost /]# docker rmi -f 镜像id #删除指定的容器
[root@localhost /]# docker rmi -f 镜像id 容器id 容器id #删除多个镜像
[root@localhost /]# docker rmi -f $(docker images -aq) #删除全部镜像
一切有关镜像命令,可选参数皆可在官方文档及 --help 查看到!
整理于
https://www.bilibili.com/video/BV1og4y1q7M4?p=9
欢迎 增改纠正提醒!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。