Calling OpenConnect VPN client in docker container shows TUNSETIFF failed: Operation not permitted Calling OpenConnect VPN client in docker container shows TUNSETIFF failed: Operation not permitted docker docker

Calling OpenConnect VPN client in docker container shows TUNSETIFF failed: Operation not permitted


By default, Docker containers are started with a reduced set of linux capabilities (see man capabilities). The reduced set doesn't include some network related functionality (presumably so that containers can't sniff traffic from the host or other containers).

To start a container with full network capabilities, either explicitly add the SYS_NET_ADMIN capability with --cap-add argument e.g:

docker run -d --cap-add SYS_NET_ADMIN myimage

Or give the container the full set of privileges with --privileged e.g:

docker run -d --privileged myimage


Either run the container privileged via

docker run -d --privileged myimage

as Adrian pointed out or run it with the NET_ADMIN capability added and pass the tunnel device e.g.:

docker run -d --cap-add NET_ADMIN --device /dev/net/tun myimage


Starting the container with --privileged. (Thanks Adrian Mouat for the answer).