Is there a way to expose socket from docker instance to container?

Is there a way to expose socket from docker instance to container?
I try to expose mariadb socket to HOST then to container(for wordpress) with proxy or disk device
for example

lxc config device add maria-container maria-socket proxy connect=unix:/home/DOCKER/mariadb/config/mysqld.sock listen=unix:/mysql.sock bind=container mode=0666

but then i got on container
mysql -S /mysql.sock -u root -p
ERROR 2013 (HY000): Lost connection to server at 'handshake: reading initial communication packet', system error: 11

Does connecting to /home/DOCKER/mariadb/config/mysqld.sock from the LXD host work?

It works

I wonder if the security.uid and security.gid settings might help?

https://linuxcontainers.org/lxd/docs/master/reference/devices_proxy/

Perhaps something is validating the connecting UID?

No change at all
I also tried another container with

raw.lxc: lxc.apparmor.profile=unconfined
security.privileged: "true"

without luck

Iā€™m not sure.

Are you able to provide reproducer steps for your setup?

1 Like

please try to:

nc -U /mysql.sock

from inside the container and show output (probably you will need to send something to the server, just send any random characters)

and then:

strace -f mysql -S /mysql.sock -u root -p