Following #1881 I updated an old question around the topic on serverfault and A.B noticed, that there is one case missing as stated in his comment.
It can happen, that a namespace is only kept alive by an open file descriptor of a program as ilustrated by A.B:
ip netns add foo add a namespace
sleep 999 4< /run/netns/foo & sleep 2 open the fd to the namespace in a background job
ip netns delete foo delete the namespace (only deletes the /run/netns/foo)
Now there exists a namespace with no process running in it and it has no bind mount so it does not show up in /proc/mounts, but it is still there and could be mounted back.
To me this seems to be a rather esoteric case, but if we want to show every namespace, these namespaces should be included.
Following #1881 I updated an old question around the topic on serverfault and A.B noticed, that there is one case missing as stated in his comment.
It can happen, that a namespace is only kept alive by an open file descriptor of a program as ilustrated by A.B:
ip netns add fooadd a namespacesleep 999 4< /run/netns/foo & sleep 2open the fd to the namespace in a background jobip netns delete foodelete the namespace (only deletes the /run/netns/foo)Now there exists a namespace with no process running in it and it has no bind mount so it does not show up in
/proc/mounts, but it is still there and could be mounted back.To me this seems to be a rather esoteric case, but if we want to show every namespace, these namespaces should be included.