Permission Denied for SO_DEBUG socket option inside docker

I’ve isolated the Permission Denied exception being thrown inside one of my test case to these lines –

ASSERT_EQ(0, getsockopt(s.getSocket(), SOL_SOCKET, SO_DEBUG, &optval, &optlen));
ASSERT_EQ(0, setsockopt(s.getSocket(), SOL_SOCKET, SO_DEBUG, &optval, optlen));

These work fine while running test executable with sudo on my local machine eg. sudo ./test/testexe and all test pass, no exception is thrown. To run these without sudo, I’ve tried setting capabilities prior to executing tests eg. sudo setcap "cap_net_admin+ep cap_net_raw+ep" test/testexe which again runs fine without sudo this time on my local machine.

  • Kubernetes on CoreOS: Proxy service max out CPU
  • Externalize to docker env
  • Brew install docker does not include docker engine?
  • Docker run without setting WORKDIR doesn't work
  • docker-compose images volumes
  • running tcpreplay with docker and boot2docker
  • The problem arises with docker where none of the methods work – neither sudo helps and exception is still thrown nor does the setcap method which successfully sets the capabilities but an error Operation not permitted is shown when executing tests.

    So is there any other way of running SO_DEBUG lines successfully but without running docker with elevated privileges since I get control only inside the docker container with my CI platform.

  • How to create a volume from a local path in a Dockerfile?
  • Using Docker for local development replacing Vagrant
  • Issues accessing Sinatra app in Docker container
  • docker postgres, fail to map volume in windows
  • 'mv' command throwing error but executing fine in docker
  • How to configure Vagrant box filesystem?
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.