-P 隨機指定映射連接埠。
[root@dyw219 ~]# docker run -dit --name rpweb -P centos/httpd 63e3783aa570fd0f813f65a2fcf4e5306b2d5e1a2d02b65d38a9c3dbdd9b5745
[root@dyw219 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 63e3783aa570 centos/httpd "/run-httpd.sh" 18 seconds ago Up 17 seconds 0.0.0.0:32768->80/tcp rpweb
[root@dyw219 ~]# docker logs rpweb AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
[root@dyw219 ~]# curl -s http://127.0.0.1:32768 | grep 'CentOS Project'
<p class="lead">The CentOS Project has nothing to do with
this website or its content,
Unless you intended to visit CentOS.org, the CentOS Project
does not have anything to do with this website,
<h2>The CentOS Project</h2>
[root@dyw219 ~]# docker stop rpweb rpweb [root@dyw219 ~]# docker rm rpweb rpweb