爱在莫斯科 发表于 2018-5-26 08:55:55

Docker学习与实践(二)

二、使用镜像
  1.获取镜像

# docker pull ubuntu:16.04
16.04: Pulling from library/ubuntu
22dc81ace0ea: Pull complete
1a8b3c87dba3: Pull complete
91390a1c435a: Pull complete
07844b14977e: Pull complete
b78396653dae: Pull complete
Digest: sha256:e348fbbea0e0a0e73ab0370de151e7800684445c509d46195aef73e090a49bd6
Status: Downloaded newer image for ubuntu:16.04
  2.查看获取的镜像

# docker image ls
  #使用--help可以查看参数选项,比如自己定义显示的列

# docker image ls --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
IMAGE ID            REPOSITORY          TAG
f975c5035748      ubuntu            16.04
f2a91732366c      hello-world         latest

  #查看空间的占用

# docker system df
  3.删除镜像
#删除本地镜像可以使用镜像短ID、长ID、镜像名或镜像摘要来删除

# docker image ls
REPOSITORY          TAG               IMAGE ID            CREATED             SIZE
ubuntu            16.04               f975c5035748      7 days ago          112MB
centos            latest            2d194b392dd1      8 days ago          195MB
mysql               latest            5d4d51c57ea8      2 weeks ago         374MB
nginx               latest            e548f1a579cf      3 weeks ago         109MB
hello-world         latest            f2a91732366c      3 months ago      1.85kB
# docker image rm 5d4
# docker image rm nginx
# docker image ls
REPOSITORY          TAG               IMAGE ID            CREATED             SIZE
ubuntu            16.04               f975c5035748      7 days ago          112MB
centos            latest            2d194b392dd1      8 days ago          195MB
hello-world         latest            f2a91732366c      3 months ago      1.85kB
  #还可以使用docker image ls命令来配合

docker image rm $(docker image ls -q ubuntu)
docker image rm $(docker image ls -q -f before=centos)
  #学习文档地址:https://github.com/yeasy/docker_practice/blob/master/SUMMARY.md
页: [1]
查看完整版本: Docker学习与实践(二)