Status: Open (View Workflow)
Jenkins 2.330, Dockerized agent on macOS
I have an inbound agent running on macOS. Its Dockerfile is as follows.
FROM jenkins/inbound-agent COPY --from=docker /usr/local/bin/docker /usr/local/bin/ USER root RUN mkdir /usr/local/.docker/ USER jenkins
When using withDockerContainer, Jenkins says it "does not seem to be running inside a container". This is not true, and it causes volume mounts to fail.
java.io.IOException: Failed to run image '<image id>'. Error: docker: Error response from daemon: Mounts denied: The paths /home/jenkins/agent/workspace/<job name>@tmp and /home/jenkins/agent/workspace/<job name> are not shared from OS X and are not known to Docker. You can configure shared paths from Docker -> Preferences... -> File Sharing. See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.
I believe the issue stems from this code being incorrect.
I found out that this is because cgroup namespace and cgroup v2 are used in in my instance of Docker. The solution is to use --cgroupns host into the container creation command. This should be documented somewhere.