Docker officially recommends that we use port mapping to provide the services of the Docker container to the host machine or other containers on the LAN. The general process is: 1. The Docker process listens to a port on the host and sends the data packet of the port to the Docker container 2. The host machine can open the firewall to allow other devices in the LAN to access the port of the host machine and then access the port of docker. But it is not very convenient in actual use. The following records the method of exposing the Docker container to the LAN through an independent IP in the win10 environment. In the default startup mode of Docker, a virtual network card is generated, and then a separate network card and IP are allocated within the container. You can see this virtual network card through the ipconfig command on the host machine. Open a container and you can see that the container IP address is automatically assigned. Cannot ping through the host machine Implementing IP intercommunication by configuring routing tables View route print View the docker ip address The port exposed to the host is 10.0.75.1 Adding Routes route -p add 172.17.0.0 MASK 255.255.255.0 10.0.75.2 Re-ping the container address Now you can access it directly through ip. Since Docker uses the bridge network by default and automatically assigns an IP each time a container is started, we can create our own network bridge1, specify the IP when creating the container, and add a route if independent IP access is required. like route -p add 172.18.12.0 MASK 255.255.255.0 10.0.75.2 If you delete a route: route delete 172.18.12.0 The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: MySQL 5.7.18 zip version installation tutorial
>>: Examples of using the ES6 spread operator
The following problem occurred when installing my...
Table of contents 1. How are structures stored in...
<div id="root"> <h2>Keep go...
1. es startup command: docker run -itd -e TAKE_FI...
Table of contents Summary of Distributed ID Solut...
1 What is BEM Naming Standard Bem is the abbrevia...
Sometimes, we need to use the hyperlink <a> ...
First configure the project artifacts Configuring...
Table of contents 1. Rendering 2. Implementation ...
Recently, when I was using C# to make a Web progra...
Because I have a database tutorial based on SQL S...
1. Install cmake 1. Unzip the cmake compressed pa...
Today, when I was practicing with the Baidu page,...
In many projects, it is necessary to implement th...