dock学习笔记

2019-05-15  本文已影响0人  桌面小鱼

从镜像仓库拉取镜像

docker pull (镜像名称)

[root@iZ2ze3gye2rcpntgyzryzbZ ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
743f2d6c1f65: Pull complete 
3f0c413ee255: Pull complete 
aef1ef8f1aac: Pull complete 
f9ee573e34cb: Pull complete 
3f237e01f153: Pull complete 
f9da32e8682a: Downloading [================================>                  ]  7.855MB/12.11MB
4b8da52fb357: Download complete 
3416ca8f6890: Download complete 
786698c2d5de: Downloading [>                                                  ]  1.612MB/88.99MB
4ddf84d07bd1: Download complete 
cd3aa23461b6: Waiting 
9f287a2a95ad: Waiting 
Digest: sha256:711df5b93720801b3a727864aba18c2ae46c07f9fe33d5ce9c1f5cbc2c035101
Status: Downloaded newer image for mysql:latest

查看docker镜像

docker images

[root@iZ2ze3gye2rcpntgyzryzbZ ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mysql               latest              990386cbd5c0        5 days ago          443MB
ubuntu              latest              d131e0fa2585        2 weeks ago         102MB

从镜像仓库查询镜像

Docker Hub 的地址是:hub.docker.com/

镜像仓库搜索结果.png
在 Docker Hub 的搜索结果中,有几项关键的信息有助于我们选择合适的镜像:
OFFICIAL 代表镜像为 Docker 官方提供和维护,相对来说稳定性和安全性较高
Stars 代表镜像的关注人数,这类似 GitHub 的 Stars,可以理解为热度
Downloads 代表镜像被拉取的次数,基本上能够表示镜像被使用的频度

除了直接通过 Docker Hub 网站搜索镜像这种方式外,我们还可以用 docker CLI 中的 docker search 这个命令搜索 Docker Hub 中的镜像。

docker search mysql

[root@iZ2ze3gye2rcpntgyzryzbZ ~]# docker search mysql
NAME                                                   DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
mysql                                                  MySQL is a widely used, open-source relation…   8142                [OK]                
mariadb                                                MariaDB is a community-developed fork of MyS…   2771                [OK]                
mysql/mysql-server                                     Optimized MySQL Server Docker images. Create…   607                                     [OK]
zabbix/zabbix-server-mysql                             Zabbix Server with MySQL database support       192                                     [OK]
hypriot/rpi-mysql                                      RPi-compatible Docker Image with Mysql          113                                     
zabbix/zabbix-web-nginx-mysql                          Zabbix frontend based on Nginx web-server wi…   101                                     [OK]
centurylink/mysql                                      Image containing mysql. Optimized to be link…   60                                      [OK]
centos/mysql-57-centos7                                MySQL 5.7 SQL database server                   52                                      
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5   ubuntu-16-nginx-php-phpmyadmin-mysql-5          50                                      [OK]
mysql/mysql-cluster                                    Experimental MySQL Cluster Docker images. Cr…   44                                      
deitch/mysql-backup                                    Automated and scheduled mysql database dumps…   34                                      [OK]
tutum/mysql                                            Base docker image to run a MySQL database se…   32                                      
zabbix/zabbix-web-apache-mysql                         Zabbix frontend based on Apache web-server w…   29                                      [OK]
schickling/mysql-backup-s3                             Backup MySQL to S3 (supports periodic backup…   27                                      [OK]
bitnami/mysql                                          Bitnami MySQL Docker Image                      26                                      [OK]
zabbix/zabbix-proxy-mysql                              Zabbix proxy with MySQL database support        22                                      [OK]
linuxserver/mysql                                      A Mysql container, brought to you by LinuxSe…   20                                      
centos/mysql-56-centos7                                MySQL 5.6 SQL database server                   13                                      
mysql/mysql-router                                     MySQL Router provides transparent routing be…   11                                      
circleci/mysql                                         MySQL is a widely used, open-source relation…   11                                      
openshift/mysql-55-centos7                             DEPRECATED: A Centos7 based MySQL v5.5 image…   6                                       
jelastic/mysql                                         An image of the MySQL database server mainta…   1                                       
ansibleplaybookbundle/mysql-apb                        An APB which deploys RHSCL MySQL                0                                       [OK]
cloudposse/mysql                                       Improved `mysql` service with support for `m…   0                                       [OK]
widdpim/mysql-client                                   Dockerized MySQL Client (5.7) including Curl…   0                                       [OK]

管理镜像

除了使用docker images查看镜像列表以外 还可以使用 docker inspect (容器ID或镜像ID) 查看镜像详情

docker inspect mysql/990386cbd5c0

[root@iZ2ze3gye2rcpntgyzryzbZ ~]# docker inspect mysql
[
    {
        "Id": "sha256:990386cbd5c04effd6669ab958aa41ce06052bbe52b8d88f259bfadf9fbf37c9",
        "RepoTags": [
            "mysql:latest"
        ],
        "RepoDigests": [
            "mysql@sha256:711df5b93720801b3a727864aba18c2ae46c07f9fe33d5ce9c1f5cbc2c035101"
        ],
        "Parent": "",
        "Comment": ""
      #··········
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

删除镜像

docker rmi (镜像ID或名称) 支持同时删除多个镜像

[root@iZ2ze3gye2rcpntgyzryzbZ ~]# docker rmi ubuntu
Untagged: ubuntu:latest
Untagged: ubuntu@sha256:70fc21e832af32eeec9b0161a805c08f6dddf64d341748379de9a527c01b6ca1
Deleted: sha256:d131e0fa2585a7efbfb187f70d648aa50e251d9d3b7031edf4730ca6154e221e
Deleted: sha256:c59a62c2bba8db73ca8b8847baa7fa77e4d573f38e57d69592a9716f9fa075c4
Deleted: sha256:a4eb6208f601c2f32e043972b9fa8e813767aef2e60676e91796cabf8a0afdc4
Deleted: sha256:a14c708b62677e8acfb75ac873147e71dd26aa7bf75a8b63b3408e0826b174dc
Deleted: sha256:604cbde1a4c8fee1b102f8b64d4f41e62d770b5f8a6b06fb809cfd873a2643c3

注:此文用来学习docker笔记之用,摘自掘金小册《开发者必备的 Docker 实践指南

上一篇下一篇

猜你喜欢

热点阅读