- 本文講解 Docker 鏡像操作的常用指令
- docker Hub 官網(wǎng):https://hub.docker.com/
鏡像操作
檢索云端鏡像
-使用 指令 docker search 關(guān)鍵字 可以檢索 (搜索) Docker Hub 官網(wǎng)上提供的所有鏡像棉钧,之后我們就可以下載需要的鏡像
-檢索 " mysql ":[root@localhost ~]# docker search mysql
-檢索 " redis ":[root@localhost ~]# docker search redis
[root@localhost ~]# docker search mysql
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/mysql MySQL is a widely used, open-source relati... 6728 [OK]
docker.io docker.io/mariadb MariaDB is a community-developed fork of M... 2141 [OK]
docker.io docker.io/mysql/mysql-server Optimized MySQL Server Docker images. Crea... 495 [OK]
docker.io docker.io/percona Percona Server is a fork of the MySQL rela... 360 [OK]
docker.io docker.io/zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 114 [OK]
docker.io docker.io/hypriot/rpi-mysql RPi-compatible Docker Image with Mysql 93
docker.io docker.io/zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server ... 62 [OK]
docker.io docker.io/centurylink/mysql Image containing mysql. Optimized to be li... 60 [OK]
docker.io docker.io/1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 43 [OK]
docker.io docker.io/centos/mysql-57-centos7 MySQL 5.7 SQL database server 35
docker.io docker.io/mysql/mysql-cluster Experimental MySQL Cluster Docker images. ... 33
docker.io docker.io/tutum/mysql Base docker image to run a MySQL database ... 32
docker.io docker.io/schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic back... 20 [OK]
docker.io docker.io/bitnami/mysql Bitnami MySQL Docker Image 16 [OK]
docker.io docker.io/zabbix/zabbix-proxy-mysql Zabbix proxy with MySQL database support 15 [OK]
docker.io docker.io/linuxserver/mysql A Mysql container, brought to you by Linux... 14
docker.io docker.io/centos/mysql-56-centos7 MySQL 5.6 SQL database server 9
docker.io docker.io/circleci/mysql MySQL is a widely used, open-source relati... 6
docker.io docker.io/openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 ima... 6
docker.io docker.io/dsteinkopf/backup-all-mysql backup all DBs in a mysql server 4 [OK]
docker.io docker.io/mysql/mysql-router MySQL Router provides transparent routing ... 2
docker.io docker.io/openzipkin/zipkin-mysql Mirror of https://quay.io/repository/openz... 1
docker.io docker.io/ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 0 [OK]
docker.io docker.io/cloudfoundry/cf-mysql-ci Image used in CI of cf-mysql-release 0
docker.io docker.io/cloudposse/mysql Improved `mysql` service with support for ... 0 [OK]
[root@localhost ~]#
INDEX:索引
NAME:鏡像名稱(chēng)
DESCRIPTION:描述
STARS:關(guān)注人數(shù),單位為 k
OFFICIAL:是否為官方發(fā)布)卷胯,[ok] 則表示此版本為官方發(fā)行版本
AUTOMATED:是否自動(dòng)配置沮峡,[ok] 則表示鏡像已經(jīng)自動(dòng)配置好了椭豫,獲取就能直接使用,否則需要自己手動(dòng)配置
- 如上所示所有的搜索結(jié)果其實(shí)都是從 Docker Hub 上獲取來(lái)的,所以我們自己也可以官網(wǎng)上直接查找
下載鏡像
- 使用命令:docker pull 鏡像名:tag等龙,可以從 Docker Hub 下載指定的鏡像督笆,“ :tag ” 不寫(xiě)時(shí)默認(rèn)下載最新版本的鏡像芦昔,也可以自己指定 tag 從而下載指定版本的鏡像,tag 名稱(chēng)可以從 Docker Hub 上自己查看
[root@localhost ~]# docker search mysql
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/mysql MySQL is a widely used, open-source relati... 6728 [OK]
docker.io docker.io/mariadb MariaDB is a community-developed fork of M... 2141 [OK]
docker.io docker.io/mysql/mysql-server Optimized MySQL Server Docker images. Crea... 495 [OK]
.......
- 下載上面 NAME 為 docker.io/msql 鏡像為例娃肿,使用 " docker pull mysql "即可下載咕缎, 前面的 " docker.io/" 可寫(xiě)可不寫(xiě)
- 如下所示沒(méi)有提供 "tag" 時(shí), “Using default tag: latest” 表示默認(rèn)使用 "latest" 版本
- 下載成功之后料扰,可以使用 " docker images " 查看本地下載好的所有鏡像
[root@localhost ~]# docker pull mysql
Using default tag: latest
Trying to pull repository docker.io/library/mysql ...
latest: Pulling from docker.io/library/mysql
be8881be8156: Pull complete
c3995dabd1d7: Pull complete
9931fdda3586: Pull complete
bb1b6b6eff6a: Pull complete
a65f125fa718: Pull complete
2d9f8dd09be2: Pull complete
37b912cb2afe: Pull complete
54242fcd8eaa: Pull complete
0a9d4d211511: Pull complete
270ae5bd02c2: Pull complete
9b55b8e72e70: Pull complete
68083f7985cd: Pull complete
Digest: sha256:d39a8ab7679df309e7eff6ddba434ad5747cc2a2acee2d7c60d8221c9acedcad
Status: Downloaded newer image for docker.io/mysql:latest
[root@localhost ~]#
如下所示下載的是 docker.io/mysql 5.7 版本的鏡像
[root@localhost ~]# docker pull mysql:5.7
Trying to pull repository docker.io/library/mysql ...
5.7: Pulling from docker.io/library/mysql
be8881be8156: Already exists
c3995dabd1d7: Already exists
9931fdda3586: Already exists
bb1b6b6eff6a: Already exists
a65f125fa718: Already exists
2d9f8dd09be2: Already exists
37b912cb2afe: Already exists
faf9da46e0cf: Pull complete
ffcedc9e8600: Pull complete
6e11f2447e86: Pull complete
02243b284270: Pull complete
Digest: sha256:e25e2768e910223db3095c1560aa2255371986b24fbebf4b015bae3cc60b9b34
Status: Downloaded newer image for docker.io/mysql:5.7
[root@localhost ~]#
查看本地鏡像
使用命令 docker images 查看本地下載好的所有鏡像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql 5.7 43b029b6b640 22 hours ago 372 MB
docker.io/mysql latest 29e0ae3b69b9 22 hours ago 484 MB
[root@localhost ~]#
REPOSITORY :倉(cāng)庫(kù)凭豪,即下載的鏡像名稱(chēng)
TAG:標(biāo)識(shí),通常為版本號(hào)
IMAGE ID:鏡像id晒杈,刪除時(shí)根據(jù)鏡像id進(jìn)行刪除
CRREATED:鏡像創(chuàng)建時(shí)間
SIZE:鏡像大小
刪除鏡像
使用 docker rmi image-id 命令刪除指定的本地鏡像
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql 5.7 43b029b6b640 22 hours ago 372 MB
docker.io/mysql latest 29e0ae3b69b9 22 hours ago 484 MB
[root@localhost ~]# docker rmi 43b029b6b640
Untagged: docker.io/mysql:5.7
Untagged: docker.io/mysql@sha256:e25e2768e910223db3095c1560aa2255371986b24fbebf4b015bae3cc60b9b34
Deleted: sha256:43b029b6b6406b40f1ba51b069980b5c14b701786830a41ebb489ad3bbf3d928
Deleted: sha256:e8793f33a59faabf48ec2b41dff592700651385fc2d0e4ddc2f7a6efbd0c03c3
Deleted: sha256:06f716d6d745ca2ab39f21f40ba757cbbd93b6189ca47030f4888442b9c2f9ca
Deleted: sha256:0c7d7ee852d955b7ec7353dc367b26ee59c029243e631fc31a53847bffe1852b
Deleted: sha256:35c70a35928fd6ce30c1495b9782b53b69fe0d023c35ad047072e4d7d388a753
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql latest 29e0ae3b69b9 22 hours ago 484 MB
[root@localhost ~]# docker rmi 29e0ae3b69b9
Untagged: docker.io/mysql:latest
Untagged: docker.io/mysql@sha256:d39a8ab7679df309e7eff6ddba434ad5747cc2a2acee2d7c60d8221c9acedcad
Deleted: sha256:29e0ae3b69b9031ab7d7fd3024057b9441d74c8244e583cfb48697109148ca71
Deleted: sha256:e510a8f0a60462d0280381e93018635f8986c308550dabce0be5249c3402c338
Deleted: sha256:7360cba3164f094ead4b968263cabeed376e7306ca6415c824d63ff7d2c22203
Deleted: sha256:e26ff419bf2626b93431acf08fc734cb88eed5dea413bd05965ba1c51dc9c671
Deleted: sha256:5b9acfeae5767ffb16ef495d68de01b750ac5efcf2af474d695b1fead7c2dabc
Deleted: sha256:3f55b1f8de59e6ba35f38376b4a7ee48ffbb32f23500d16400a18c6d59ad1803
Deleted: sha256:d8a947a6bf007b7b3f857fd157092aa938cc01780175eda5c300847f2758ba6f
Deleted: sha256:424c40c7a715a28330453b0ec3b5afc97caa851a56d365c65a97b583b733b81b
Deleted: sha256:202db300227b8c870b421aa0a0a11b44cb916401ef3a34bcc2a5efcb30a3ea78
Deleted: sha256:20f3dff2c1b6f8409b53e4e203132f7ebb2dfd7dc612d87e4a93302a5a8f5c1a
Deleted: sha256:3131a4917b53634699929d8ff7e2b2bd9469f3f5ab08daf41d1c6b90e0f18b44
Deleted: sha256:9996a15396359708cb2177cfdbe8fcb9f65124142edb9b1d3550f3eb87360676
Deleted: sha256:cdb3f9544e4c61d45da1ea44f7d92386639a052c620d1550376f22f5b46981af
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@localhost ~]#