Issue
I'm getting an error when creating a network namespace inside a docker container saying permission denied.
command
ip netns add red
error
mount --make-shared /run/netns failed: Permission denied
I am running an image ubuntu:20.10 and tried by adding specific capabilities to the container and it did not help.
docker run -it --rm --name=ubuntu --cap-add CAP_SYS_ADMIN --cap-add NET_ADMIN ubuntu:20.10
apt-get update && apt-get install -y net-tools && apt-get install -y iproute2
Even after adding all capabilities issue remain same.
docker run -it --rm --name=ubuntu --cap-add ALL ubuntu:20.10
Solution
--cap-add
& --privileged
are not same.
Ref: https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
Issue is sorted by running the container with privilege. Capabilities seems not required for adding network namespace.
docker run -d --name=<name> --network=none --privileged <image>:<tag>
Answered By - Isuru Amarathunga Answer Checked By - Gilberto Lyons (WPSolving Admin)