Skip to content
Advertisement

Why this error occurs ‘You must run the container in the host namespace when running privileged mode’?

I have enabled user namespaces and now I wanted to run a docker container with –privileged flag, yes I know it’s a bad practice but still I wanted to run that docker as –privileged.

But I can see this error pops-up, so was curious what is this error? What am I doing wrong?

docker: Error response from daemon: privileged mode is incompatible to user namespaces. You must run the container in the host namespace when running privileged mode'

Advertisement

Answer

set --userns host on the docker run command.

From docker docs they said:

If you enable user namespaces on the daemon, all containers are started with user namespaces enabled by default. In some situations, such as privileged containers, you may need to disable user namespaces for a specific container. To disable user namespaces for a specific container, add the --userns=host flag to the docker container create, docker container run, or docker container exec command.

docker: Error response from daemon: privileged mode is incompatible to user namespaces. You must run the container in the host namespace when running privileged mode'

It is pretty clear in the error, to run your container with --previleged you have to run your container in the host namespace not in the custom namespace.

Advertisement