-
查看当前Docker的版本信息;
root@willem:~# docker version Client: Version: 1.11.1 API version: 1.23 Go version: go1.5.4 Git commit: 5604cbe Built: Tue Apr 26 23:30:23 2016 OS/Arch: linux/amd64 Server: Version: 1.11.1 API version: 1.23 Go version: go1.5.4 Git commit: 5604cbe Built: Tue Apr 26 23:30:23 2016 OS/Arch: linux/amd64
-
查看Docker帮助信息;
使用过程中可以使用Docker提供的帮助功能查看命令的用法与相关信息。docker --help
-
Docker基本语法;
Usage: docker [OPTIONS] COMMAND [arg...] docker daemon [ --help | ... ] docker [ --help | -v | --version ] A self-sufficient runtime for containers.
-
选项;
Options: # 指定Docker客户端配置文件的路径; --config=~/.docker Location of client config files # 是否使用Debug模式,默认为false; -D, --debug Enable debug mode # 在daemon模式下绑定的socket,通过一个或多个 tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd来指定; -H, --host=[] Daemon socket(s) to connect to # 查看帮助信息,-h 和 --help 是一样的; -h, --help Print usage # 设置日志等级,-l 和 --log-level 是一样的; -l, --log-level=info Set the logging level # 是否开启tls,默认为false; --tls Use TLS; implied by --tlsverify # 指定CA(Certificate Authority认证授权机构)签名的信任证书的路径; --tlscacert=~/.docker/ca.pem Trust certs signed only by this CA # 指定TLS证书文件的路径; --tlscert=~/.docker/cert.pem Path to TLS certificate file # 指定TLS公钥文件的路径; --tlskey=~/.docker/key.pem Path to TLS key file # 使用TLS并验证远程控制主机; --tlsverify Use TLS and verify the remote # 输出Docker的版本信息(简略)并退出 -v, --version Print version information and quit
-
命令;
Commands: # 依附到一个正在运行的容器中; attach Attach to a running container # 依据Dockerfile文件构建镜像; 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 on a container's filesystem # 从服务端获取实时的事件; events Get real time events from the server # 在运行的容器中执行命令; exec Run a command in a running container # 将一个容器的文件系统导出为一个tar包; export Export a container's filesystem as a tar archive # 显示一个镜像的构建历史信息(镜像的构建步骤记录-类似Dockerfile); history Show the history of an image # 查询镜像列表; images List images # 从tarball导入内容创建一个文件系统映像; import Import the contents from a tarball to create a filesystem image # 显示整个系统的信息; info Display system-wide information # 获取容器或镜像的低级信息; inspect Return low-level information on a container or image # 关闭一个正在运行的容器(包括进程和所有相关资源); kill Kill a running container # 从一个tar包或STDIN中加载一个镜像; load Load an image from a tar archive or STDIN # 登陆Docker注册服务器(上传镜像需要先登录); login Log in to a Docker registry # 登出Docker注册服务器(注销); logout Log out from a Docker registry # 获取一个容器的日志信息; logs Fetch the logs of a container # 管理容器的网络配置; network Manage Docker networks # 暂停一个容器内的所有进程; pause Pause all processes within a container # 列出一个容器的端口映射或一个特定映射的信息; 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 a container # 删除一个或多个容器; rm Remove one or more containers # 删除一个或多个镜像; rmi Remove one or more images # 在一个新的容器中运行一个命令; run Run a command in a new container # 将一个或多个镜像保存为一个tar包; save Save one or more images to a tar archive # 在Docker Hub中搜索镜像; search Search the Docker Hub for images # 启动一个或多个暂停的容器; start Start one or more stopped containers # 动态显示容器资源的使用情况;例如“docker stats 8981”信息如下: # CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O BLOCK I/O PIDS # 8981 0.00% 3.551MB/4.145GB 0.09% 509.6kB/14.15MB 2.028MB/0 B 0 stats Display a live stream of container(s) resource usage statistics # 停止一个正在运行的容器; stop Stop a running container # 修改本地仓库中镜像的标签; tag Tag an image into a repository # 显示一个容器中正在运行的进程; top Display the running processes of a container # 解除一个容器中所有进程的暂停状态; unpause Unpause all processes within a container # 更新一个或多个容器的配置; update Update configuration of one or more containers # 显示Docker的版本信息(详细) version Show the Docker version information # 管理Docker的数据卷; volume Manage Docker volumes # 阻塞,直到一个容器停止,然后输出它的退出代码 wait Block until a container stops, then print its exit code # 运行“docker COMMAND --help”获取更多的指令信息,如指令的用途与参数的详细解释。 Run 'docker COMMAND --help' for more information on a command.
-
举例说明;
想要查看run命令的使用方法和参数含义-“docker run --help”。docker run --help
返回信息-run命令的用法说明;
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Run a command in a new container
返回信息-run命令的参数说明;
-a, --attach=[] Attach to STDIN, STDOUT or STDERR --add-host=[] Add a custom host-to-IP mapping (host:ip) --blkio-weight Block IO (relative weight), between 10 and 1000 --blkio-weight-device=[] Block IO weight (relative device weight) --cpu-shares CPU shares (relative weight) --cap-add=[] Add Linux capabilities --cap-drop=[] Drop Linux capabilities --cgroup-parent Optional parent cgroup for the container --cidfile Write the container ID to the file --cpu-period Limit CPU CFS (Completely Fair Scheduler) period --cpu-quota Limit CPU CFS (Completely Fair Scheduler) quota --cpuset-cpus CPUs in which to allow execution (0-3, 0,1) --cpuset-mems MEMs in which to allow execution (0-3, 0,1) -d, --detach Run container in background and print container ID --detach-keys Override the key sequence for detaching a container --device=[] Add a host device to the container --device-read-bps=[] Limit read rate (bytes per second) from a device --device-read-iops=[] Limit read rate (IO per second) from a device --device-write-bps=[] Limit write rate (bytes per second) to a device --device-write-iops=[] Limit write rate (IO per second) to a device --disable-content-trust=true Skip image verification --dns=[] Set custom DNS servers --dns-opt=[] Set DNS options --dns-search=[] Set custom DNS search domains -e, --env=[] Set environment variables --entrypoint Overwrite the default ENTRYPOINT of the image --env-file=[] Read in a file of environment variables --expose=[] Expose a port or a range of ports --group-add=[] Add additional groups to join -h, --hostname Container host name --help Print usage -i, --interactive Keep STDIN open even if not attached --ip Container IPv4 address (e.g. 172.30.100.104) --ip6 Container IPv6 address (e.g. 2001:db8::33) --ipc IPC namespace to use --isolation Container isolation technology --kernel-memory Kernel memory limit -l, --label=[] Set meta data on a container --label-file=[] Read in a line delimited file of labels --link=[] Add link to another container --log-driver Logging driver for container --log-opt=[] Log driver options -m, --memory Memory limit --mac-address Container MAC address (e.g. 92:d0:c6:0a:29:33) --memory-reservation Memory soft limit --memory-swap Swap limit equal to memory plus swap: '-1' to enable unlimited swap --memory-swappiness=-1 Tune container memory swappiness (0 to 100) --name Assign a name to the container --net=default Connect a container to a network --net-alias=[] Add network-scoped alias for the container --oom-kill-disable Disable OOM Killer --oom-score-adj Tune host's OOM preferences (-1000 to 1000) -P, --publish-all Publish all exposed ports to random ports -p, --publish=[] Publish a container's port(s) to the host --pid PID namespace to use --pids-limit Tune container pids limit (set -1 for unlimited) --privileged Give extended privileges to this container --read-only Mount the container's root filesystem as read only --restart=no Restart policy to apply when a container exits --rm Automatically remove the container when it exits --security-opt=[] Security Options --shm-size Size of /dev/shm, default value is 64MB --sig-proxy=true Proxy received signals to the process --stop-signal=SIGTERM Signal to stop a container, SIGTERM by default -t, --tty Allocate a pseudo-TTY --tmpfs=[] Mount a tmpfs directory -u, --user Username or UID (format:
[: ]) --ulimit=[] Ulimit options --userns User namespace to use --uts UTS namespace to use -v, --volume=[] Bind mount a volume --volume-driver Optional volume driver for the container --volumes-from=[] Mount volumes from the specified container(s) -w, --workdir Working directory inside the container -
查看Docker守护进程的模式配置的帮助信息;
docker daemon --help
用法说明;
Usage: docker daemon [OPTIONS] Enable daemon mode
参数说明;
--api-cors-header Set CORS headers in the remote API --authorization-plugin=[] List authorization plugins in order from first evaluator to last -b, --bridge Attach containers to a network bridge --bip Specify network bridge IP --cgroup-parent Set parent cgroup for all containers --cluster-advertise Address or interface name to advertise --cluster-store Set the cluster store --cluster-store-opt=map[] Set cluster store options --config-file=/etc/docker/daemon.json Daemon configuration file --containerd Path to containerd socket -D, --debug Enable debug mode --default-gateway Container default gateway IPv4 address --default-gateway-v6 Container default gateway IPv6 address --default-ulimit=[] Set default ulimits for containers --disable-legacy-registry Do not contact legacy registries --dns=[] DNS server to use --dns-opt=[] DNS options to use --dns-search=[] DNS search domains to use --exec-opt=[] Set runtime execution options --exec-root=/var/run/docker Root directory for execution state files --fixed-cidr IPv4 subnet for fixed IPs --fixed-cidr-v6 IPv6 subnet for fixed IPs -G, --group=docker Group for the unix socket -g, --graph=/var/lib/docker Root of the Docker runtime -H, --host=[] Daemon socket(s) to connect to --help Print usage --icc=true Enable inter-container communication --insecure-registry=[] Enable insecure registry communication --ip=0.0.0.0 Default IP when binding container ports --ip-forward=true Enable net.ipv4.ip_forward --ip-masq=true Enable IP masquerading --iptables=true Enable addition of iptables rules --ipv6 Enable IPv6 networking -l, --log-level=info Set the logging level --label=[] Set key=value labels to the daemon --log-driver=json-file Default driver for container logs --log-opt=map[] Set log driver options --mtu Set the containers network MTU -p, --pidfile=/var/run/docker.pid Path to use for daemon PID file --raw-logs Full timestamps without ANSI coloring --registry-mirror=[] Preferred Docker registry mirror -s, --storage-driver Storage driver to use --selinux-enabled Enable selinux support --storage-opt=[] Set storage driver options --tls Use TLS; implied by --tlsverify --tlscacert=~/.docker/ca.pem Trust certs signed only by this CA --tlscert=~/.docker/cert.pem Path to TLS certificate file --tlskey=~/.docker/key.pem Path to TLS key file --tlsverify Use TLS and verify the remote --userland-proxy=true Use userland proxy for loopback traffic --userns-remap User/Group setting for user namespaces