Create a link to the Unix socket
6,427
Linux at least would allow you to use a bind mount to make either a directory or alternatively a single file available at multiple places.
# mount --bind /var/MySQL.sock /chroot/var/MySQL.sock
Related videos on Youtube
Author by
eRIZ
Updated on September 18, 2022Comments
-
eRIZ over 1 year
Is there a possibility to create a hard link for an unix socket? I'm creating a jail and symbolic links won't work, so I'm looking for a solution, how to provide an unix socket inside chrootted environment.
The only idea I'm coming across is to use something like netcat but is there any reliable possibility?
-
eRIZ about 10 yearsBind works only for directories, so it doesn't solve the problem.
-
HBruijn about 10 yearsIn the words of the man page
One can also remount a single file (on a single file)
, and I have no problems accessing the MySQL daemon through the socket in the bind mount. But I don't have any chroot set up to test more. -
eRIZ about 10 yearsParameter list consist on two directories. I mean mounting a link directly, without separated directory. Could you provide your command line I can test against? Is this the above you cited? I tried to make it happen but this doesn't work.
-
Falcon Momot about 10 yearsYou can also put the socket in a directory created for this purpose, and bind mount that.
-
eRIZ about 10 years@FalconMomot, I know but I want to solve problem. I'm aware of a workaround. [;
-
Falcon Momot about 10 yearsHow does that not solve the problem? Bind the directory the socket goes in, see to it that it goes in there, and you're done.
-
eRIZ about 10 yearsDoesn't solve - it enforces me creating a separated directory for various set of sockets. I want to specify it more flexible, so is that why I asked for a particular link for a socket if it's possible.
-
Gert van den Berg almost 5 yearsI know Docker uses single file bind mounts, but the bind command does not accept them. (And your mount command parameters is wrong, it is
--bind
or-t none -o bind
) -
Xunnamius about 4 yearsHBruijn's is the correct answer (with @GertvandenBerg's fix). Thanks for this! See: mardy.it/blog/2018/10/how-to-bind-mount-single-file.html