Docker run command summary

1. docker run command

docker run: Create a new container and run a command

The following are some parameters that can be added when docker run

2. Parameters specified by docker run

1. -d

Run the container in the background and return the container ID. At this time, the interactive interface will not be entered. If you want to enter the interactive interface, please add the -i and -t parameters.

If you use the -d parameter and do not enter the container, and want to enter the container, the command: docker exec -it container name/bin/bash;

2.-i

-i: Run the container in interactive mode, usually used together with -t;

3.-t

-t: Reassign a pseudo input terminal to the container, usually used together with -i;

4. -P

-P: Random port mapping, the container’s internal port is randomly mapped to the host’s port

5. -p

-p: Specify port mapping, the format is: host (host) port: container port

6. --name

–name="xxxxx": Specify a name for the container, the name is xxxxx;

7. --dns

–dns 8.8.8.8: Specify the DNS server used by the container, which defaults to the same as the host;

8. -e

-e username="ritchie": Set environment variables;

9. -cpuset

–cpuset="0-2" or --cpuset="0,1,2": Bind the container to the specified CPU to run;

10. -m

-m: Set the maximum memory used by the container;

11. -net

–net="bridge": Specify the network connection type of the container, supporting bridge/host/none/container: four types;

12. -link

–link=[]: add a link to another container;

13. -expose

–expose=[]: Open a port or a group of ports;

14. -v

–volume, -v: Bind a volume

Guess you like

Origin blog.csdn.net/qulian2099/article/details/130819315