How to directly access the docker for windows container intranet through an independent IP

How to directly access the docker for windows container intranet through an independent IP

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:
  • Docker intranet builds DNS and uses domain name access instead of ip:port operation
  • Solution to slow network request in docker container
  • Method for accessing independent IP in Docker container
  • How to build a private server in docker (docker-registry with nginx&ssl on centos)
  • Detailed explanation of building lanproxy intranet penetration service based on docker
  • Steps to deploy multiple tomcat services using DockerFile on Docker container
  • Docker image creation, uploading, pulling and deployment operations (using Alibaba Cloud)
  • Analysis of the implementation process of Docker intranet penetration frp deployment

<<:  MySQL 5.7.18 zip version installation tutorial

>>:  Examples of using the ES6 spread operator

Recommend

MySQL character types are case sensitive

By default, MySQL character types are not case-se...

Method of building redis cluster based on docker

Download the redis image docker pull yyyyttttwwww...

Native JS implements a very good-looking counter

Today I will share with you a good-looking counte...

Summary of Common Problems with Mysql Indexes

Q1: What indexes does the database have? What are...

How to use Docker container to access host network

Recently, a system was deployed, using nginx as a...

Sample code of uniapp vue and nvue carousel components

The vue part is as follows: <template> <...

How to insert a link in html

Each web page has an address, identified by a URL...

Pitfall notes of vuex and pinia in vue3

Table of contents introduce Installation and Usag...

Detailed explanation of how to implement secondary cache with MySQL and Redis

Redis Introduction Redis is completely open sourc...

Detailed explanation of how components communicate in React

1. What is We can split the communication between...

MySQL 5.7.17 winx64 installation and configuration method graphic tutorial

Windows installation mysql-5.7.17-winx64.zip meth...

Mysql solution to improve the efficiency of copying large data tables

Preface This article mainly introduces the releva...

MySQL 5.7.17 installation and configuration tutorial for Mac

1. Download MySQL Click on the official website d...

Summary of fragmented knowledge of Docker management

Table of contents 1. Overview 2. Application Exam...