Docker 镜像常用命令

一 列出镜像列表
使用docker images来列出本地主机上的镜像。
[root@localhost ~]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
docker.io/ubuntu        latest              0ef2e08ed3fa        2 weeks ago         130 MB
docker.io/hello-world   latest              48b5124b2768        9 weeks ago         1.84 kB
docker.io/ubuntu        15.10               9b9cb95443b5        7 months ago        137.2 MB
各个选项说明:
REPOSTITORY:表示镜像的仓库源。
TAG:镜像的标签。
IMAGE ID:镜像ID。
CREATED:镜像创建时间。
SIZE:镜像大小。
同一仓库源可以有多个TAG,代表这个仓库源的不同个版本,如ubuntu仓库源里,有15.10、latest等多个不同的版本,我们使用REPOSTITORY:TAG来定义不同的镜像。
所以,我们如果要使用版本为15.10的ubuntu系统镜像来运行容器时,命令如下:
[root@localhost ~]# docker run -t -i ubuntu:15.10 /bin/bash
root@e26a0172a0aa:/#  
如果要使用版本为latest的ubuntu系统镜像来运行容器时,命令如下:
[root@localhost ~]# docker run -t -i ubuntu:latest /bin/bash
root@bf67651b183f:/# 
如果不指定一个镜像的版本标签,例如只使用 ubuntu,docker 将默认使用 ubuntu:latest 镜像。
 
二 获取一个新的镜像
当在本地主机上使用一个不存在的镜像时,Docker就会自动下载这个镜像。如果想预先下载这个镜像,可以使用docker pull命令来下载它。
[root@localhost ~]# docker pull ubuntu
Using default tag: latest
Trying to pull repository docker.io/library/ubuntu ... 
latest: Pulling from docker.io/library/ubuntu
d54efb8db41d: Pull complete 
f8b845f45a87: Pull complete 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值