Docker(一)镜像常用命令

docker学习官方文档是非常全的,随时可以翻看。

docker images  #查看所有本地的主机上的镜像

[]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    d1a364dc548d   6 weeks ago   148MB
mysql        latest    c0cdc95609f1   8 weeks ago   575MB

# 解释
REPOSITORY        镜像的仓库源
TAG               镜像的标签
IMAGE ID          镜像的id
CREATED           镜像的创建时间
SIZE              镜像的大小

#可选项
    -a, --all        #列出所有镜像
[]# docker images -a
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
nginx        latest    d1a364dc548d   6 weeks ago   148MB
mysql        latest    c0cdc95609f1   8 weeks ago   575MB

    -q, --quiet      #只显示镜像的id
[]# docker images -aq
d1a364dc548d
c0cdc95609f1

docker search 搜索镜像

[]# docker search centos
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
centos                            The official build of CentOS.                   6630      [OK]
ansible/centos7-ansible           Ansible on Centos7                              134                  [OK]
consol/centos-xfce-vnc            Centos container with "headless" VNC session…   129                  [OK]
jdeathe/centos-ssh                OpenSSH / Supervisor / EPEL/IUS/SCL Repos - …   118                  [OK]
centos/systemd                    systemd enabled base container.                 100                  [OK]
centos/mysql-57-centos7           MySQL 5.7 SQL database server                   88
imagine10255/centos6-lnmp-php56   centos6-lnmp-php56                              58                   [OK]
tutum/centos                      Simple CentOS docker image with SSH access      48
centos/postgresql-96-centos7      PostgreSQL is an advanced Object-Relational …   45
jdeathe/centos-ssh-apache-php     Apache PHP - CentOS.                            31                   [OK]
kinogmt/centos-ssh                CentOS with SSH                                 29                   [OK]
guyton/centos6                    From official centos6 container with full up…   10                   [OK]
nathonfowlie/centos-jre           Latest CentOS image with the JRE pre-install…   8                    [OK]
centos/tools                      Docker image that has systems administration…   7                    [OK]
drecom/centos-ruby                centos ruby                                     6                    [OK]
mamohr/centos-java                Oracle Java 8 Docker image based on Centos 7    3                    [OK]
darksheer/centos                  Base Centos Image -- Updated hourly             3                    [OK]
amd64/centos                      The official build of CentOS.                   2
miko2u/centos6                    CentOS6 日本語環境                                   2                    [OK]
dokken/centos-7                   CentOS 7 image for kitchen-dokken               2
indigo/centos-maven               Vanilla CentOS 7 with Oracle Java Developmen…   2                    [OK]
mcnaughton/centos-base            centos base image                               1                    [OK]
blacklabelops/centos              CentOS Base Image! Built and Updates Daily!     1                    [OK]
starlabio/centos-native-build     Our CentOS image for native builds              0                    [OK]
smartentry/centos                 centos with smartentry                          0                    [OK]

# 可选项,搜索过滤
    --filter=STARTS=3000    # 搜索出来的镜像就是STARS大于3000的
[]# docker search centos --filter=STARS=3000
NAME      DESCRIPTION                     STARS     OFFICIAL   AUTOMATED
centos    The official build of CentOS.   6630      [OK]


docker pull 拉取镜像

拉取镜像是通过Docker Hub来拉取,在网站上可以搜索到对应镜像的各个版本信息及对应的“TAG

# 下载镜像 docker pull 镜像名[:tag]
[]# docker pull centos
Using default tag: latest    # 如果不写 tag, 默认就是 latest 最新版本
latest: Pulling from library/centos
7a0437f04f83: Pull complete    # 分层下载, docker iamge的核心联合文件系统
Digest: sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1    # 签名
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest    # 真实地址


# 等价
docker pull centos
docker docker.io/library/centos:latest

# 指定下载版本 centos7
[]# docker pull centos:7
7: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest: sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e
Status: Downloaded newer image for centos:7
docker.io/library/centos:7

# 查看下下载好的镜像,可以看到不同的版本
[]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    d1a364dc548d   6 weeks ago    148MB
mysql        latest    c0cdc95609f1   8 weeks ago    575MB
centos       latest    300e315adb2f   7 months ago   237MB
centos       7         8652b9f0cb4c   7 months ago   227MB

docker rmi 删除镜像

[]# docker rmi -f 镜像ID    # 删除指定的镜像
[]# docker rmi -f 镜像ID 镜像ID 镜像ID 镜像ID    # 删除指定的多个镜像
[]# docker rmi -f $(docker search -aq)    # 删除全部的镜像

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值