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.

  • How to disable the root access of a docker container?
  • Docker with a Virtual Sound Card for Stream Altering
  • Installing ssh-keyscan on Alpine linux?
  • Connecting postgres from typeorm docker container
  • Tool to automate Docker Swarm
  • How I can connect wp container with ajenti container?
  • 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 sync dir from a container to a dir from the host?
  • Docker run using “some name/alias”
  • Failed to connect to master, spark in docker
  • Is it possible to set the default command when the `docker exec` command is run on an already running container?
  • Is using phusion/baseimage still worth it? [closed]
  • Docker API questions
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.