The Docker Run command is used to run a new container, and starting a container requires a lot of information, so there are a lot of parameters to this command, and the parameters supported by the command are analyzed in detail today.
First look at the format of the command:
Usage:docker Run [OPTIONS] IMAGE [COMMAND] [ARG ...] -A,--attach=[] login container (container started with Docker run-d)-C,--cpu-shares=0 set container CPU weight, use--cap-add=[in CPU sharing scenario] Add permissions, permissions list see: http://linux.die.net/man/7/capabilities--cap-drop=[] Delete permissions, permissions list see: http://linux.die.ne T/man/7/capabilities--cidfile= "" After running the container, write the container PID value in the specified file, a typical monitoring system usage--cpuset= "" To set what the container can use CPU, this parameter can be used to container exclusive cpu-d,--detach=false Specify whether the container runs in the foreground or background--device=[] Add the host device to the container, equivalent to the device direct--dns=[] Specify the container's DNS server--dns-search=[] Specify the DNS search domain name of the container, write to the container's/etc/resolv.conf file-E,--env=[] Specifies the environment variable, which can be used in a container--entrypoint= "" Overrides the image's entry point--env-file=[] To specify the environment variable file, with a file format of one environment variable per line--ex Pose=[] Specifies the port exposed by the container, that is, to modify the exposed port of the mirror-H,--hostname= "" To specify the container's hostname-I,--interactive=false open stdin, to control System Interaction--link=[] Specifies the association between containers, using other containers ' IP, env, and other information--lxc-conf=[]The container's configuration file, using-M only when specifying--EXEC-DRIVER=LXC,--memory= "" Specifies the container's upper memory--name= "" Specifies the container name, which can subsequently be container tube by name The links feature needs to use the name--net= "Bridge" container network settings, to detail-p,--publish-all=false specify the port exposed by the container, to be detailed-P,--publish=[] Specifies the port exposed by the container, to be detailed--privileged=false Specifies whether the container is a privileged container, and the privileged container has all capabilities--restart= "" Specifies that the container stops after the restart Policy, to be detailed--rm=false the container is automatically deleted after the container is stopped (the container started with Docker run-d is not supported)--sig-proxy=true settings are accepted and processed by the proxy, but SIGC HLD, Sigstop, and Sigkill cannot be proxy-T,--tty=false assign TTY devices, which can support terminal login-U,--user= "" Specify container User-V,--volum E=[] mount a storage volume to a container, mount it to a directory in the container--volumes-from=[] mount the volume on the other container to the container, mount it to a directory of the container-W,--workdir= "" To specify the container The Working directory
Fault Handling
The--restart parameter supports three logical implementations:
</pre><pre name= "code" class= "HTML" >no: Container exits without restarting
on-failure: container failure exits (return value not 0) Restart
always: container exits with a reboot
Port exposure -P parameter: Docker automatically maps exposed ports;
Docker run-d-P training/webapp <span style= "color: #009900;" >//docker automatically opens 49000 to 49900 ports on host, mapped to exposed ports of the container (specified by the mirror, or--expose parameter);</span>
-P parameter: Specify the port or IP to be mapped;
Docker run-d-P 5000:80 training/webapp <span style= "color: #009900;" >//host on port No. 5000, map to container exposed 80 ports;</span>
Docker run-d-P 127.0.0.1:5000:80 training/webapp <span style= " Color: #009900; " >//host on 127.0.0.1:5000 port, mapped to container exposed 80 ports;</span>
Docker run-d-P 127.0.0.1::5000 Training/webapp < Span style= "color: #009900;" >//host 127.0.0.1: Random port, mapped to container exposed 80 port;</span>
Docker run-d-P 127.0.0.1:5000:5000/udp Training/webapp <span style= "color: #009900;" >//binding UDP port;</span>
Network Configuration
--net=bridge: <span style= "color: #009900;" >//using Docker daemon specified bridge </span>
--net=host: <span style= "color: #009900;" >//Container uses the host's network </span>
--net=container:name_or_id:<span style= "color: #009900;" >//use other container networks, share IP and port network resources </span>
--net=none: <span style= "color: #009900;" >//containers use their own networks (similar to--net=bridge), but do not configure </span>