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.

  • docker build fails on a cloud VM
  • How do you remove the contents of a docker volume?
  • How to monitor docker container disk access metrics when using overlayFS
  • Copy from docker to host inside CI build
  • Getting “can't cd” error when when building using dockerfile
  • Timeout pushing image to nexus inside container docker
  • 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 use local docker images in Kubernetes?
  • Automated Dockerfile generator
  • Multilayer Docker Deployment on AWS
  • How to mount image in docker whose storage driver is devicemapper
  • Spring Boot and Nginx integration
  • Issue executing python script in Docker
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.