6.Ubuntu16.04Docker查看和删除镜像

来源:互联网 发布:陕西天互数据 编辑:程序博客网 时间:2024/05/18 03:48

Ubuntu16.04Docker查看和删除镜像

什么是Docker的镜像

  • 容器的基石
  • 层叠的只读文件系统
  • 联合加载
graph LRbootfs-->rootfsrootfs-->add-emacsadd-emacs-->add-apache

Docker镜像存储的位置

Root Dir: /var/lib/docker/aufs

eggyer@ubuntu:/usr/local$ docker infoContainers: 11Images: 6Server Version: 1.9.1Storage Driver: aufs Root Dir: /var/lib/docker/aufs Backing Filesystem: extfs Dirs: 28 Dirperm1 Supported: trueExecution Driver: native-0.2Logging Driver: json-fileKernel Version: 4.4.0-47-genericOperating System: Ubuntu 16.04.1 LTS (containerized)CPUs: 4Total Memory: 3.842 GiBName: ubuntuID: WBMI:TD6B:PRUN:XWSX:5RVV:QUYO:5S27:W74L:MQ3W:YDB7:JXPL:NR5XWARNING: No swap limit support
eggyer@ubuntu:/usr/local$ sudo ls -l /var/lib/docker/aufsdrwxr-xr-x 30 root root 4096 1125 12:41 diffdrwxr-xr-x  2 root root 4096 1125 12:41 layersdrwxr-xr-x 30 root root 4096 1125 12:41 mnt查看mnt中的文件eggyer@ubuntu:/usr/local$ sudo ls -l /var/lib/docker/aufs/mnt总用量 112drwxr-xr-x 2 root root 4096 1125 10:47 0409e42a2dd26d643bc9d3b7e0cc6642cd4d690f5431d3633ca5ba14126ad633drwxr-xr-x 2 root root 4096 1125 10:47 0409e42a2dd26d643bc9d3b7e0cc6642cd4d690f5431d3633ca5ba14126ad633-initdrwxr-xr-x 2 root root 4096 1125 02:36 0d2ba69dbe3ebda7e9473d1db0f49e98115888586f10761709c02d8cca1d702fdrwxr-xr-x 2 root root 4096 1125 11:58 142b9f902b69f1f05f971977018266074587ed11ac953f92a2aaf467d3ad140fdrwxr-xr-x 2 root root 4096 1125 11:58 142b9f902b69f1f05f971977018266074587ed11ac953f92a2aaf467d3ad140f-initdrwxr-xr-x 2 root root 4096 1125 10:38 29a7330714d833270e0c6e0a580e9374974c47db8e54324ee62a9f15c69da103drwxr-xr-x 2 root root 4096 1125 10:38 29a7330714d833270e0c6e0a580e9374974c47db8e54324ee62a9f15c69da103-initdrwxr-xr-x 2 root root 4096 1125 02:36 2f5519d4ff74257f28f7c2099c09998fc75193ac8df22543d3d2263934da0992drwxr-xr-x 2 root root 4096 1125 12:18 327d5a30f1868441afa84ef2d662231e81208de400ddcf7627d3d716a5544b23drwxr-xr-x 2 root root 4096 1125 12:18 327d5a30f1868441afa84ef2d662231e81208de400ddcf7627d3d716a5544b23-initdrwxr-xr-x 2 root root 4096 1125 12:41 3b1e8b137e4ef0419086d79fd1018c20e9c4d7269c74fb235d882f2484677e51drwxr-xr-x 2 root root 4096 1125 12:41 3b1e8b137e4ef0419086d79fd1018c20e9c4d7269c74fb235d882f2484677e51-initdrwxr-xr-x 2 root root 4096 1125 02:36 594949f005feb4a4c43f5e6773bc34eae7befa8bfdee4242a5e28c0b0edbb1a4drwxr-xr-x 2 root root 4096 1125 02:36 67de889be9457b9b22e6faf87d2faa45e823236486c75f86c2b1f7e436b262b5drwxr-xr-x 2 root root 4096 1125 02:36 6d75c02d3deeb73247665df9dbd74b60018676d7fa3a360c41e027420be19161drwxr-xr-x 2 root root 4096 1125 02:36 6d75c02d3deeb73247665df9dbd74b60018676d7fa3a360c41e027420be19161-initdrwxr-xr-x 2 root root 4096 1125 12:00 6fa6e815583eb3ccd9758c0238b5213d9d532d5e34b85f5f181103d679871fb1drwxr-xr-x 2 root root 4096 1125 12:00 6fa6e815583eb3ccd9758c0238b5213d9d532d5e34b85f5f181103d679871fb1-initdrwxr-xr-x 2 root root 4096 1125 11:45 ba87d27bc76b4f146884c4805af21c25a7bbbdd87229503f7e186fb0ccd63c2edrwxr-xr-x 2 root root 4096 1125 11:45 ba87d27bc76b4f146884c4805af21c25a7bbbdd87229503f7e186fb0ccd63c2e-initdrwxr-xr-x 2 root root 4096 1125 02:36 bea8f41ae3e812e19e2b011bb78a268f386e2089320d1c48caf7dca3df39b15fdrwxr-xr-x 2 root root 4096 1125 02:41 c6128de0b863d00cb8af724d9b222c3aa080929e4328391e499dd49aae5adf1edrwxr-xr-x 2 root root 4096 1125 02:41 c6128de0b863d00cb8af724d9b222c3aa080929e4328391e499dd49aae5adf1e-initdrwxr-xr-x 2 root root 4096 1125 12:19 ed4d220ff1641c25f2a09d98ca782b0b2fce83757afe9f425720f8bee88ae363drwxr-xr-x 2 root root 4096 1125 12:19 ed4d220ff1641c25f2a09d98ca782b0b2fce83757afe9f425720f8bee88ae363-initdrwxr-xr-x 2 root root 4096 1125 02:36 ed6ff6865688f1f4e131482c7bbe7ada713271be7948902ebcb86dec27c4ff1cdrwxr-xr-x 2 root root 4096 1125 10:34 f6bf839a4bd5c60b68a9671ec8cd21102b703f2c48731f2b5875ff89f4bff148drwxr-xr-x 2 root root 4096 1125 10:34 f6bf839a4bd5c60b68a9671ec8cd21102b703f2c48731f2b5875ff89f4bff148-init

列出镜像

docker images [OPTIONS][repsitory]-a --all=false-f --filter=[]--no-trunc=false (不使用截断的形式 ID)-q --quiet=false (只显示镜像的唯一ID)
eggyer@ubuntu:/usr/local$ docker imagesREPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZEubuntu              latest              bea8f41ae3e8        9 days ago          128.1 MB

REPOSITORY

一个镜像关联了一个REPOSITORY,一个REPOSITORY关联了一系列镜像
比如ubuntu就是一个仓库,其下边不同的镜像表示ubuntu不同的版本.
和之前讲到的REGISTRY仓库不同,REGISTRY是DOCKER的一系列组件,其包含了很多REPOSITORY

TAG

镜像的标签,不同的镜像以标签的形式区分;
同一个镜像可以使用不同的标签;
docker run ubuntu命令默认使用latest标签的ubuntu镜像.

使用notrunc查看完成的ID

eggyer@ubuntu:/usr/local$ docker images --no-truncREPOSITORY          TAG                 IMAGE ID                                                           CREATED             VIRTUAL SIZEubuntu              latest              bea8f41ae3e812e19e2b011bb78a268f386e2089320d1c48caf7dca3df39b15f   9 days ago          128.1 MB

只显示镜像名ID

eggyer@ubuntu:/usr/local$ docker images -qbea8f41ae3e8

根据repository查看镜像

eggyer@ubuntu:/usr/local$ docker images ubuntuREPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZEubuntu              latest              bea8f41ae3e8        9 days ago          128.1 MB

查看镜像的详细信息

docker inspect [options] CONTAINER|IMAGE[CONTAINER|image]-f --format=""eggyer@ubuntu:/usr/local$ docker inspect ubuntu:latest[{    "Id": "bea8f41ae3e812e19e2b011bb78a268f386e2089320d1c48caf7dca3df39b15f",    "RepoTags": [        "ubuntu:latest"    ],    "RepoDigests": [],    "Parent": "0d2ba69dbe3ebda7e9473d1db0f49e98115888586f10761709c02d8cca1d702f",    "Comment": "",    "Created": "2016-11-16T20:58:26.830045089Z",    "Container": "c450b5337e9f0b1e408f45d76031d56219542c7ebe416c6d872694abcb7e5a33",    "ContainerConfig": {        "Hostname": "fb8ca5e4ccd2",        "Domainname": "",        "User": "",        "AttachStdin": false,        "AttachStdout": false,        "AttachStderr": false,        "Tty": false,        "OpenStdin": false,        "StdinOnce": false,        "Env": [            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"        ],        "Cmd": [            "/bin/sh",            "-c",            "#(nop) ",            "CMD [\"/bin/bash\"]"        ],        "Image": "sha256:53ba9532a0d83bd4db49e5dbb11a2db0b5e9004669a030143a2c0a3f251bf900",        "Volumes": null,        "WorkingDir": "",        "Entrypoint": null,        "OnBuild": null,        "Labels": {}    },    "DockerVersion": "1.12.3",    "Author": "",    "Config": {        "Hostname": "fb8ca5e4ccd2",        "Domainname": "",        "User": "",        "AttachStdin": false,        "AttachStdout": false,        "AttachStderr": false,        "Tty": false,        "OpenStdin": false,        "StdinOnce": false,        "Env": [            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"        ],        "Cmd": [            "/bin/bash"        ],        "Image": "sha256:53ba9532a0d83bd4db49e5dbb11a2db0b5e9004669a030143a2c0a3f251bf900",        "Volumes": null,        "WorkingDir": "",        "Entrypoint": null,        "OnBuild": null,        "Labels": {}    },    "Architecture": "amd64",    "Os": "linux",    "Size": 0,    "VirtualSize": 128115414,    "GraphDriver": {        "Name": "aufs",        "Data": null    }}]

删除docker镜像

docker rmi [OPTIONS] IMAGE [IMAGE...]-f --force=false  强制删除镜像--no-prune=false 保留镜像中被打标签的父镜像删除时若使用IMAGE名和TAG名的形式则每次会删除一个,如果一个镜像有多个TAG那么只有当最后一个IMAGE +TAG被删除时镜像菜会被删除若使用IMAGEID可以删除其对应的多个IMAGE+TAG
0 0
原创粉丝点击