Docker run command
docker run: to create a new container and run a command
grammar
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
OPTIONS Description:
-a stdin: standard input output Optional STDIN / STDOUT / STDERR three;
-d: background container and return the container ID;
-i: Run vessel in interactive mode, usually used in conjunction with -t;
-t: a pseudo reallocate container terminal input, typically used in conjunction with -i;
--name = "nginx-lb": specify a name for the container;
--dns 8.8.8.8: DNS server to use the specified container, the default host and consistent;
--dns-search example.com: container specified DNS search domain name, the default host and consistent;
-h "mars": hostname specified container;
-e username = "ritchie": set environment variables;
--env-file = []: reads environment variables from the specified file;
--cpuset = "0-2" or --cpuset = "0,1,2": binding container to the specified CPU is running;
-m: Setting the maximum memory use containers;
--net = "bridge": the network connection type specified container, support for bridge / host / none / container:
Four types; --link = []: add a link to another vessel;
--expose = []: open a port or a group of ports;
Examples
Use docker mirror nginx: After the latest station mode starts a container, and the container is named mynginx.
docker run --name mynginx -d nginx:latest
Mirroring nginx: After the latest station mode starts a container, the container port and 80 maps to the host random port.
docker run -P -d nginx:latest
Mirroring nginx: After the latest station mode starts a container, the container will map port 80 to port 80 of the host, the host directory / data mapped to the container / data.
docker run -p 80:80 -v /data:/data -d nginx:latest
Mirroring nginx: latest in interactive mode to start a container, Executive / bin / bash command within the container.
w3big@w3big:~$ docker run -it nginx:latest /bin/bash root@b8573233d675:/#