ip моей хост-машины 192.168.8.100
Вот мой ipconfig в Windows10
Ethernet adapter Ethernet:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : DHCP HOST
Ethernet adapter vEthernet (Default Switch):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::cd90:1c37:f269:c1b5%10
IPv4 Address. . . . . . . . . . . : 172.21.93.241
Subnet Mask . . . . . . . . . . . : 255.255.255.240
Default Gateway . . . . . . . . . :
Ethernet adapter vEthernet (DockerNAT):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::a80e:8b65:b853:7976%13
IPv4 Address. . . . . . . . . . . : 10.0.75.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
Ethernet adapter VirtualBox Host-Only Network:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::dcad:f104:d3ff:60f%7
IPv4 Address. . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
Ethernet adapter Npcap Loopback Adapter:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::f85f:91c6:fcb6:c971%21
Autoconfiguration IPv4 Address. . : 169.254.201.113
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :
Wireless LAN adapter Local Area Connection* 1:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Local Area Connection* 2:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::e58a:9017:15ae:2a26%17
IPv4 Address. . . . . . . . . . . : 192.168.8.100
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.8.1
Я создаю новую подсеть из докера От docker-compose.yml
db:
image: mysql:8.0
container_name: onlinecodedb
volumes:
- onlinecode-database:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: mysqlrootpassword
MYSQL_PASSWORD: mysqlpassword
MYSQL_USER: mysql
MYSQL_DATABASE: onlinecode
ports:
- "3300:3306"
networks:
- onlinecode-net
networks:
onlinecode-net:
driver: bridge
С docker network inspect onlinecode_onlinecode-net
[
{
"Name": "onlinecode_onlinecode-net",
"Id": "b915ecd03a9acdb0d28b8b355dca0a479a186c2b5e6fbb35efb81de1684aa63d",
"Created": "2018-10-02T02:17:36.4110372Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"0730d1115929f5b476116fd6147782bf15d7f469fb7203779d2d8f5953bdea49": {
"Name": "onlinecodeapp",
"EndpointID": "aa0c0bf03740e500821b1f00d0da2f09d3642723035e0b2e384ac18746bf182a",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
},
"c3abc13980d415dd0a6494e3e5113847448e004f3b720f1603c826ebbaa2b9db": {
"Name": "onlinecodedb",
"EndpointID": "7e5261e88fcded21e1864906de976ed1c2d5b30d4c94ae65375bf21e0035706c",
"MacAddress": "02:42:ac:12:00:03",
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "onlinecode-net",
"com.docker.compose.project": "onlinecode",
"com.docker.compose.version": "1.22.0"
}
}
]
onlinecodedb
в ip B class range
но мой локальный хост в C range
Итак, как мне подключиться к mysql с 192.168 до 172.18?Я не могу найти тот же вопрос из stackoverflow
Я гуглил два дня, кто-то сказал: эй, тебе следует использовать Gateway и Router.
Но как мне сопоставить 172 с 192?все они частные IP, а не публичные.
Я знаю, что этот вопрос глуп, это проблема компьютерной сети, но, пожалуйста, помогите мне решить эту проблему.