How to share /dev/shm between unprivileged containers?

I’d like to configure two unprivileged containers so that they can perform inter-container IPC. They need to share /dev/shm, as well as ipc, user and net namespaces.

It’s easy enough to share namespaces between containers via the following lxc config options:

 lxc.namespace.share.ipc        = name_of_container
 lxc.namespace.share.user       = name_of_container
 lxc.namespace.share.net        = name_of_container
 lxc.namespace.share.cgroup     = name_of_container

But what is the best way to share /dev/shm between containers? (It must be different from the host’s /dev/shm.)

1 Like

I’d say setup a tmpfs somewhere on the host (probably under /run) and then bind-mount that into both containers. That’s likely easier than trying to grab a reference to the first container’s /devshm

1 Like

Will do. Thanks!