description of the previous article :
Windows host ip:10.100.70.135
Linux virtual machine ip:192.168.233.129
Docker container ip:172.17.0.11
for the convenience of testing, we typically choose to Install the virtual machine in the Windows host (this is VMware workstation) and deploy Docker in the virtual machine container. the outer network of containers that we deploy in Docker (and the network on the same layer of windows) is inaccessible.
In order to solve this problem, we can use this scheme.
First, When creating a container, you can choose the port mapping feature that comes with Docker to implement 172.17.0.11 and 192.168.233.129 across the network the communication. Refer to the command below, Other uses of Docker are not described here
Docker run-it-p 8003:80--name nginx1 Cariden/centos6.7/bin/bash
here we can map to 172.17.0.11 's 80 by accessing the 8003 Port of the 192.168.233.129 access to nginx Services directly.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/8A/A6/wKiom1g2XVjxyPkTAAAeOnaGH_k762.png "title=" Picture 1.png "alt=" Wkiom1g2xvjxypktaaaeonagh_k762.png "/>
in the Docker deploys an external service for access and creates a simple index page
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/8A/A6/wKiom1g2XUix-QKQAAAM3cSBR3o567.png "title=" Picture 2.png "alt=" Wkiom1g2xuix-qkqaaam3csbr3o567.png "/>
Second, use vmware 's own virtual network editor for external network access to services within a virtual machine
1. Click "Edit", "Virtual Network editor",
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/8A/A2/wKioL1g2XWTzwbcbAAD7iJjMHMY460.png "title=" Picture 3.png "alt=" Wkiol1g2xwtzwbcbaad7ijjmhmy460.png "/>
2. Selectnat, and then clickNat settings.
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/8A/A6/wKiom1g2XXTSB6nNAACzQMOSgt0227.png "title=" Picture 4.png "alt=" Wkiom1g2xxtsb6nnaaczqmosgt0227.png "/>
3. Next Click "Add" to have the 8004 port of the access host mapped to the 8003 port in the virtual machine .
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/8A/A2/wKioL1g2XYCSFb8mAABx-hVoV7Y482.png "title=" Picture 5.png "alt=" Wkiol1g2xycsfb8maabx-hvov7y482.png "/>
4. in the pop-up interface, fill in the host port, the virtual machine IP, the virtual machine port ,
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/8A/A6/wKiom1g2XY7A5eIUAAA_MWpOJS4513.png "title=" Picture 6.png "alt=" Wkiom1g2xy7a5eiuaaa_mwpojs4513.png "/>
5. when determined, we map the port number in the virtual machine to the 8086 port on the host . Can be tested on the external network, choose and host the same layer of other machines to do the test.
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/8A/A2/wKioL1g2XZ7CO6PsAABL4S9OUTI733.png "title=" Picture 7.png "alt=" Wkiol1g2xz7co6psaabl4s9outi733.png "/>
6. Test Pass!
Note: If the above steps are still inaccessible, consider the firewall problem, you can open 8004 port in the firewall entry rules , here to facilitate testing I turned off the firewall.
This article is from the "7286083" blog, please be sure to keep this source http://7296083.blog.51cto.com/7286083/1876077
The external network accesses the Web App in Docker deployed in the virtual machine via port mapping