On my home network (normal internal IP range 192.168.0.0.0), in preparation for working with a VPC network which dictates my containers should run on a 10.0.0.0/16 subnet, I am trying to set up a docker container running mysql server which is accessible to other machines in a network.
I am trying to make the following setup:
-
Create a bridged Docker 10.0.0.0/16 subnet
-
Run a docker container with mysql server on one laptop, assigned to an IP address within the 10.0.0.0/16 range
-
Make sure that port 3306 on the docker container is open by changing bind-address = 0.0.0.0 for the container instance of mysql-server
-
On the host laptop, use a mysql client to test that the server can be accessed via the assigned IP 10.0.0.2:3306 (SUCCESS)
-
On another laptop in the same network try to ping the 10.0.0.2 IP address (FAIL) and use a mysql client to access via the assigned IP 10.0.0.2:3306 (FAILURE)
The commands I have run for this are:
docker network create --driver bridge --subnet 10.0.0.0/16 --gateway 10.0.0.1 my-network
docker run --network=my-network -p 3306:3306 -d --cap-add=NET_ADMIN --cap-add=SYS_MODULE --env-file credentials/my-vpn-credentials.env my-docker-image:latest
Then docker exec -it magical_meninsky bash
to setup the mysql server in the running container.
The output of `ifconfig’ on the host laptop is:
br-eb22a51280b1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 10.0.0.1 netmask 255.255.0.0 broadcast 10.0.255.255
ether 02:42:f8:4b:d4:ef txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:fe:5b:f4:62 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 7812 bytes 835168 (835.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 7812 bytes 835168 (835.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.73 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 2a02:c7f:7e19:3e00:4511:82f3:6f62:8414 prefixlen 64 scopeid 0x0<global>
inet6 fd35:45d2:cc02:0:c13:6d1c:7583:d2f0 prefixlen 64 scopeid 0x0<global>
inet6 2a02:c7f:7e19:3e00:c13:6d1c:7583:d2f0 prefixlen 64 scopeid 0x0<global>
inet6 fd35:45d2:cc02:0:a0ed:62b1:bd7a:ea55 prefixlen 64 scopeid 0x0<global>
inet6 fe80::c821:db0f:889b:23f7 prefixlen 64 scopeid 0x20<link>
ether 9c:b6:d0:88:fc:75 txqueuelen 1000 (Ethernet)
RX packets 761839 bytes 509857747 (509.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 446722 bytes 256891288 (256.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Can anybody suggest why I am unable to access the container from the other laptop on the home network?