docker

linux,ubuntu 2019-08-26 1070 次浏览 次点赞


I. docker

II. docs

image

CommandDescription
docker image buildBuild an image from a Dockerfile
docker image historyShow the history of an image
docker image importImport the contents from a tarball to create a filesystem image
docker image inspectDisplay detailed information on one or more images
docker image loadLoad an image from a tar archive or STDIN
docker image lsList images
docker image pruneRemove unused images
docker image pullPull an image or a repository from a registry
docker image pushPush an image or a repository to a registry
docker image rmRemove one or more images
docker image saveSave one or more images to a tar archive (streamed to STDOUT by default)
docker image tagCreate a tag TARGET_IMAGE that refers to SOURCE_IMAGE

container

CommandDescription
docker container attachAttach local standard input, output, and error streams to a running container
docker container commitCreate a new image from a container’s changes
docker container cpCopy files/folders between a container and the local filesystem
docker container createCreate a new container
docker container diffInspect changes to files or directories on a container’s filesystem
docker container execRun a command in a running container
docker container exportExport a container’s filesystem as a tar archive
docker container inspectDisplay detailed information on one or more containers
docker container killKill one or more running containers
docker container logsFetch the logs of a container
docker container lsList containers
docker container pausePause all processes within one or more containers
docker container portList port mappings or a specific mapping for the container
docker container pruneRemove all stopped containers
docker container renameRename a container
docker container restartRestart one or more containers
docker container rmRemove one or more containers
docker container runRun a command in a new container
docker container startStart one or more stopped containers
docker container statsDisplay a live stream of container(s) resource usage statistics
docker container stopStop one or more running containers
docker container topDisplay the running processes of a container
docker container unpauseUnpause all processes within one or more containers
docker container updateUpdate configuration of one or more containers
docker container waitBlock until one or more containers stop, then print their exit codes

III. dirs

有些疑问,先前错误的理解了image和container的关系,以为container是运行时(running time)的image,其实原文描述的意思是可运行的(runable)。然后可运行的container的再区分正在运行和为未运行的。

那么还有一个问题,docker image和container各自在磁盘的哪里?是否可以备份和删除。

graph LR
a[Dockerfile]--docker build-->b[image]--docker create-->c[containner]-- "docker (container) start"-->d[running]
b--docker run-->d
# tree -L 2 /var/lib/docker
/var/lib/docker
├── builder
│   └── fscache.db
├── buildkit
│   ├── cache.db
│   ├── content
│   ├── executor
│   ├── metadata.db
│   └── snapshots.db
├── containers          #容器相关配置文件
│   ├── 8e0a0480df05d9ed5f048d8bfe00c7b5735cb22376409126127c3f59407cd629
│   ├── 9892bfd530a1851985b1791c78b0001d420713647cb93cf71a050f1f97c85353
│   └── c64403de18d9435c935b4a9a3fdf2fd3a4ade8da03624e32702c3083186e7efc
├── image
│   └── overlay2       #镜像,不包含镜像文件,看起是配置文件;
├── network
│   └── files
├── overlay2           #容器、镜像、容器运行差异文件;
│   ├── 1f3492ed2c3ed859daa533057e8b05d667f8401f64c7dfb59033b45489a62bf2
│   ├── 2604ee693ddb1e99bfcb3da7b0cc9653dcb0e49c91d6ba0d2efb74cc90a3331a
│   ├── 2604ee693ddb1e99bfcb3da7b0cc9653dcb0e49c91d6ba0d2efb74cc90a3331a-init
│   ├── 60b8db6fd346f67d3ef86008a6d9cda264ae23307b7645724083a4b454ac5428
│   ├── 71c73bf0c06709216a4b2cb897fc2168d97ab0388a2687764f6f8ae5a4ccdab4
│   ├── 8ea40cec5c4646a32e2068847c8ef36a5d938cbd52e68408854b79f2736f9cb7
│   ├── 8ea40cec5c4646a32e2068847c8ef36a5d938cbd52e68408854b79f2736f9cb7-init
│   ├── bf0565d56baeb559a41271e4b6de85111486ff71542d8198b406e04a977e80c4
│   ├── bf0565d56baeb559a41271e4b6de85111486ff71542d8198b406e04a977e80c4-init
│   ├── fc9daf65ce0b47bb9f46d528bda503cfaab55ef0eeda58bc09f52453f3c73215
│   └── l
├── plugins
│   ├── storage
│   └── tmp
├── runtimes
├── swarm
├── tmp
├── trust
└── volumes
    └── metadata.db


本文由 Jay 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处,点赞3

还不快抢沙发

添加新评论