I have the network settings below.
I can access the machine with the host IP without problem.
But when the host is not connected to a network I don’t know how to reach the container.
Since I use host IP to connect machines between them (eg. wordpress backend with db) I also have to change ip configuration everytime host’s IP changes.
I guess there is another way of doing it.
Below the network settings of the image and the dockerfile
"NetworkSettings": {
"Bridge": "",
"SandboxID": "b2343a479f716a64ba32ba63dee69bc7a3cf9e9eaf5d37a16a7b552af830eb72",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"443/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "843"
}
],
"80/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "90"
}
],
"8080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "8080"
}
]
},
"SandboxKey": "/var/run/docker/netns/b2343a479f71",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"centos7_bnet": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"portal",
"dcdae133542e"
],
"NetworkID": "de7015e503266b0f4ef3bb38f6fb8ff7e650fe8dceeb7eae78985ef61cff753e",
"EndpointID": "2ad74353c168b97bb0159f282268469c96bab743d3430e1afadbc8e22db6bc22",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:03",
"DriverOpts": null
}
}
relevant part of docker-compose
version: ‘2’
services:
db:
image: mysql:5.7
networks:
- bnet
ports:
- “3366:3306”
portal:
image: centos7
networks:
- bnet
ports:
- “90:80”
- “8080:8080”
- “843:443”
networks:
bnet: