Hello everyone.
I have an LXD container and i have installed docker inside the LXD container as described here
(Running Docker inside of a LXD container - YouTube)
Inside the LXD container i have deployED a mariaDB instance from the offical docker repo.
I ran the docker container with the -p option in order for the docker container to be accessible from processes outside the LXD container.
I have a python script at the host OS which tries to connect to the mariaDB container but i receive:
ERROR:root:2003 (HY000): Can’t connect to MySQL server on ‘10.35.66.110:3306’ (111)
which indicates that the network connection has been refused.
I ran tcpdump inside the LXD container and the traffic arrives normally at port 3306 which is the mariadb’s default port.
ip a gives the following:
root@batterystation:/home/ubuntu# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:3e:06:dd:5a brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:3eff:fe06:dd5a/64 scope link
valid_lft forever preferred_lft forever
8: eth0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:bd:6d:3a brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.35.66.110/24 brd 10.35.66.255 scope global dynamic eth0
valid_lft 2628sec preferred_lft 2628sec
inet6 fe80::216:3eff:febd:6d3a/64 scope link
valid_lft forever preferred_lft forever
while ip r gives
root@batterystation:/home/ubuntu# ip r
default via 10.35.66.1 dev eth0 proto dhcp src 10.35.66.110 metric 100
10.35.66.0/24 dev eth0 proto kernel scope link src 10.35.66.110
10.35.66.1 dev eth0 proto dhcp scope link src 10.35.66.110 metric 100
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
root@batterystation:/# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c36722cca4a8 bsdb_image "docker-entrypoint.s…" 10 seconds ago Up 4 seconds 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp bsdb
The bsdb_image isn’t something special. It is the official mariadb image plus a .sql configuration which just simple create some tables
I figure out what’s the problem. I had forgotten to set the -e parameter MARIADB_DATABASE when i was starting the docker container . The fact that I was starting the mariadb container with -d ( detach mode) was preventing me from seeing the logs of the docker container and figure out the solution.