docker基础-命令

摘要

待续。。。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

Usage: docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
--config string Location of client config files (default "/root/.docker")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/root/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit

Management Commands:
config Manage Docker configs
container Manage containers
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes

Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
镜像操作:
build Build an image from a Dockerfile
commit Create a new image from a container's changes
images List images
load Load an image from a tar archive or STDIN
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rmi Remove one or more images
search Search the Docker Hub for images
tag Tag an image into a repository
save Save one or more images to a tar archive (streamed to STDOUT by default)
history 显示某镜像的历史
inspect 获取镜像的详细信息

容器及其中应用的生命周期操作:
create Create a new container (创建一个容器)
kill Kill one or more running containers
inspect Return low-level information on a container, image or task
pause Pause all processes within one or more containers
ps List containers
rm Remove one or more containers (删除一个或者多个容器)
rename Rename a container
restart Restart a container
run Run a command in a new container (创建并启动一个容器)
start Start one or more stopped containers (启动一个处于停止状态的容器)
stats Display a live stream of container(s) resource usage statistics (显示容器实时的资源消耗信息)
stop Stop one or more running containers (停止一个处于运行状态的容器)
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
wait Block until a container stops, then print its exit code
attach Attach to a running container
exec Run a command in a running container
port List port mappings or a specific mapping for the container
logs 获取容器的日志

容器文件系统操作:
cp Copy files/folders between a container and the local filesystem
diff Inspect changes on a container's filesystem
export Export a container's filesystem as a tar archive
import Import the contents from a tarball to create a filesystem image

Docker registry 操作:
login Log in to a Docker registry.
logout Log out from a Docker registry.

Volume 操作
volume Manage Docker volumes

网络操作
network Manage Docker networks

Swarm 相关操作
swarm Manage Docker Swarm
service Manage Docker services
node Manage Docker Swarm nodes

系统操作:
version Show the Docker version information
events Get real time events from the server (持续返回docker 事件)
info Display system-wide information (显示Docker 主机系统范围内的信息)

docker run

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
cgroups 和 namespace 相关:
--blkio-weight value Block IO (relative weight), between 10 and 1000
--blkio-weight-device value Block IO weight (relative device weight) (default [])
--cgroup-parent string Optional parent cgroup for the container
--cpu-percent int CPU percent (Windows only)
--cpu-period int Limit CPU CFS (Completely Fair Scheduler) period
--cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota
-c, --cpu-shares int CPU shares (relative weight)
--cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
--device-read-bps value Limit read rate (bytes per second) from a device (default [])
--device-read-iops value Limit read rate (IO per second) from a device (default [])
--device-write-bps value Limit write rate (bytes per second) to a device (default [])
--device-write-iops value Limit write rate (IO per second) to a device (default [])
--ipc string IPC namespace to use
-m, --memory string Memory limit
--memory-reservation string Memory soft limit
--memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--memory-swappiness int Tune container memory swappiness (0 to 100) (default -1)
--kernel-memory string Kernel memory limit
-u, --user string Username or UID (format: <name|uid>[:<group|gid>])
--userns string User namespace to use
--uts string UTS namespace to use
-h, --hostname string Container host name
--pid string PID namespace to use
--pids-limit int Tune container pids limit (set -1 for unlimited)
--isolation string Container isolation technology
--io-maxbandwidth string Maximum IO bandwidth limit for the system drive (Windows only)
--io-maxiops uint Maximum IOps limit for the system drive (Windows only)

linux process capabilities 相关参数:
--cap-add value Add Linux capabilities (default [])
--cap-drop value Drop Linux capabilities (default [])

容器运行模式和环境相关:
-d, --detach Run container in background and print container ID
-e, --env value Set environment variables (default [])
--env-file value Read in a file of environment variables (default [])

DNS 相关:
--dns value Set custom DNS servers (default [])
--dns-opt value Set DNS options (default [])
--dns-search value Set custom DNS search domains (default [])

健康检查相关:
--health-cmd string Command to run to check health
--health-interval duration Time between running the check
--health-retries int Consecutive failures needed to report unhealthy
--health-timeout duration Maximum time to allow one check to run
--no-healthcheck Disable any container-specified HEALTHCHECK

IP 和端口:
--ip string Container IPv4 address (e.g. 172.30.100.104)
--ip6 string Container IPv6 address (e.g. 2001:db8::33)
-p, --publish value Publish a container's port(s) to the host (default [])
-P, --publish-all Publish all exposed ports to random ports
--expose value Expose a port or a range of ports (default [])
--mac-address string Container MAC address (e.g. 92:d0:c6:0a:29:33)
--add-host value Add a custom host-to-IP mapping (host:ip) (default [])

Volume 相关:
-v, --volume value Bind mount a volume (default [])
--volume-driver string Optional volume driver for the container
--volumes-from value Mount volumes from the specified container(s) (default [])
--storage-opt value Storage driver options for the container (default [])

Network 有关:
--network string Connect a container to a network (default "default")
--network-alias value Add network-scoped alias for the container (default [])
--link value Add link to another container (default [])
--link-local-ip value Container IPv4/IPv6 link-local addresses (default [])

日志有关:
--log-driver string Logging driver for the container
--log-opt value Log driver options (default [])

交互性有关:
-a, --attach value Attach to STDIN, STDOUT or STDERR (default [])
-i, --interactive Keep STDIN open even if not attached

OOM 有关:
--oom-kill-disable Disable OOM Killer
--oom-score-adj int Tune host's OOM preferences (-1000 to 1000)

其它(待更进一步分类):
--cidfile string Write the container ID to the file
--detach-keys string Override the key sequence for detaching a container
--device value Add a host device to the container (default [])
--disable-content-trust Skip image verification (default true)
--entrypoint string Overwrite the default ENTRYPOINT of the image
--group-add value Add additional groups to join (default [])
--help Print usage
-l, --label value Set meta data on a container (default [])
--label-file value Read in a line delimited file of labels (default [])
--name string Assign a name to the container
--privileged Give extended privileges to this container
--read-only Mount the container's root filesystem as read only
--restart string Restart policy to apply when a container exits (default "no")
--rm Automatically remove the container when it exits
--runtime string Runtime to use for this container
--security-opt value Security Options (default [])
--shm-size string Size of /dev/shm, default value is 64MB
--sig-proxy Proxy received signals to the process (default true)
--stop-signal string Signal to stop a container, SIGTERM by default (default "SIGTERM")
--sysctl value Sysctl options (default map[])
--tmpfs value Mount a tmpfs directory (default [])
-t, --tty Allocate a pseudo-TTY
--ulimit value Ulimit options (default [])
-w, --workdir string Working directory inside the container