Given this bug.cpp file:
#include <thread>
int main() {
auto t = std::thread([] {});
t.join();
return 0;
}
And this docker container:
FROM ubuntu:22.04
RUN sed -i -e 's/^APT/# APT/' -e 's/^DPkg/# DPkg/' /etc/apt/apt.conf.d/docker-clean
RUN apt-get update -y
RUN apt-get install -y g++
compiling the example with:
#!/usr/bin/env sh
docker build -t test:0 -f Dockerfile .
docker run -u $(id -u):$(id -g) -v $(pwd):/src -w /src test:0 bash -c "g++ -pthread -o bug bug.cpp && ./bug"
fails with:
terminate called after throwing an instance of 'std::system_error'
what(): Operation not permitted
Replacing ubuntu:22.04
with ubuntu:20.04
and ubuntu:21.10
does work, so my hypothesis is that something has changed in how Ubuntu 22.04 handles pthreads
.
What changed from Ubuntu 21.10 to 22.04 that breaks this and how do I fix it?
PS: the sed
above is required because something else broke in Ubuntu 22.04 as well that prevents installing any packages in docker containers...