Original: http://106.13.73.98/__/104/
Docker is about to open port mapping port mapping to host the container port, which provides access to external networks.
First, let's download mirror for the test port mapping:
[root@fedora ~]# docker pull training/webapp
After the download is complete, start the following operations.
Random port mapping
execution command to below the random port 5000 is mapped to the host port of the container:[root@fedora ~]# docker -d -P training/webapp python app.py
To view port mapping information mapping:
[root@fedora ~]# docker port inspiring_mcnulty 5000/tcp -> 0.0.0.0:32768 # 容器的5000端口被映射到了宿主机的32768端口
Check process in the container information:
[root@fedora ~]# docker top b0b UID PID PPID C STIME TTY TIME CMD root 4676 4656 0 08:20 ? 00:00:00 python app.py
Monitoring container logs:
[root@fedora ~]# docker logs -f 9505707c12ad
Open a browser to access:
It is mapped to the specified port
Run the following commands to map port 5000 to port 9000 of container host port:[root@fedora ~]# docker run -d -p 9000:5000 training/webapp python app.py
Well, the same steps as above, to test it.
Original: http://106.13.73.98/__/104/