[root@docker01 /]# docker run -d -p 9999:5000 --name web training/webapp
####小p ,容器的5000端口随机映射到宿主机的9999端口
78068be818e2bb7917c97363ce2e6bc5cf1ebeb1741ff6594b2ee1e352afd07c [root@docker01 /]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 78068be818e2 training/webapp "python app.py" 14 seconds ago Up 13 seconds 0.0.0.0:9999->5000/tcp web [root@docker01 /]# docker port web 5000/tcp -> 0.0.0.0:9999
[root@docker01 /]# docker run -d -P --name web training/webapp ####大p ,容器的5000端口随机映射到宿主机的随机端口 1ad2b424f6bf74a2140111a3b581ed10975bfc1bd8b8f24a24c3763e4169e60f [root@docker01 /]# docker port web 5000/tcp -> 0.0.0.0:32778 [root@docker01 /]# docker ps -l CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1ad2b424f6bf training/webapp "python app.py" 11 seconds ago Up 10 seconds 0.0.0.0:32778->5000/tcp web
docker 网络: