0

I have a docker container, which has CPP code in it.

void SetRealtimeThreadPriority()
{
    sched_param const param{ThreadPriorities::Priority()};
    int result = pthread_setschedparam(pthread_self(), ThreadPriorities::Policy(), &param);
    printf("SetRealtimeThreadPriority - result checked for assertion %d \n", result);
    assert(result == 0); (void) result;
}

when I run the exe which has this code in ubuntu machine it works fine, where result printed is 0(zero). but when I run it in container, the assert is failing.

I have gone through multiple threads, man pages, docker run documentation and articles and tried running the container with below options, but no luck.

docker run -it --rm --cap-add SYS_NICE MyContainer
docker run --cap-add=ALL --privileged MyContainer
docker run --cap-add=ALL MyContainer
docker run -it --rm --userns host --cap-add SYS_NICE MyContainer

How can I debug this issue? Im running docker on wsl ubuntu 16.04.

Brgv
  • 21
  • 5
  • Did you verify that the result is EPERM? – Botje Aug 26 '21 at 11:31
  • @Botje how can I check the result, I am running the docker in windows machine on wsl terminal im just getting the error as below: ``TimedCallbackManager.cpp:27: void OSA::SetRealtimeThreadPriority(): Assertion result == 0 failed.`` Im running the container as root user – Brgv Aug 26 '21 at 12:56
  • did you solve it? – oak Jun 14 '22 at 10:31

1 Answers1

0

You could insert some code. Perhaps you can tell what is different? For example, #include <sys/capability.h>, and link with ... -lcap, put this:

std::cout << cap_to_text(cap_get_proc(), NULL) << std::endl;

just before the call to pthread_setschedparam(2). Does it display something different inside and outside the container?

Tinkerer
  • 865
  • 7
  • 9