Sample Header Ad - 728x90

How can I use a bind mount in a network namespace?

5 votes
1 answer
2892 views
I have an app I run in a network namespace. This works well. I want to run the app multiple times, in different namespaces. For convenience, I want to bind mount the app's working directory to something like /tmp/nsX, inside of the namespace. If I just do mount --bind /tmp/nsX /var/lib/my-app in the namespace, the mount goes away when I exit the namespace. By enter/exit the namespace, I mean just ip netns exec bash I'm looking at unshare and nsenter but I can't figure out what to do. I want to: - Configure networking for a namespace - Create a bind mount for my app's working dir, in the namespace. - Spawn my app in the namespace. It has a "fork" option if that helps. - Be able to leave and enter the namespace(s) without things dying or disappearing. If I need to use some of the other namespace types, that's fine.
Asked by sea chub (215 rep)
Jan 13, 2022, 02:14 AM
Last activity: Feb 19, 2022, 01:40 PM