Save disk space by sharing (avoiding duplication) of installed tests between phoronix-test-suite run locally and run as a docker container.
The approach
The directory containing tests can be volume or bind mounted to the docker container.
Volume mount: docker run -it -v pts-data:/var/lib/phoronix-test-suite:z phoronix/pts
Bind mount: docker run -it -v ~/.phoronix-test-suite:/var/lib/phoronix-test-suite:z phoronix/pts
The problems
Volume mount: the test installations are in a docker volume and not shared with the local pts installation. Duplication of the tests takes up a lot of space. eg. 2X ~15GB for ~30 tests
Bind mount: docker runs as root and ends up taking ownership of files/directories to which it writes in ~/.phoronix-test-suite as well as changing the selinux context from unconfined_u:object_r:user_home_t:s0 to system_u:object_r:container_file_t:s0 for the entire directory. This breaks things for my user.
Is it possible to get the docker container running properly, able to install tests, write results to a mounted volume, while not messing up permissions and selinux context for my local user?
Is building an image with that installed into the image an option?
Does docker need to run as root? Or can you add your user to the docker group and run the container as that user. It still quite likely will change the se-linux context though. But it wont change ownership to root.
Otherwise making the container priviledged might resolve this too. It may not require special se-linux context. But I am absolutely not sure about that. Something you can try though.
Not sure what you mean, but ideally I’d rather not have to create custom images and just use what pts provides and set some options to get the behavior I want. Increasingly, it seems that’s not possible.
I mean the user in the docker container is root. I’m running docker as my own user, though the docker daemon always runs as root, and I did add my user to the docker group. But since the container’s user is root, anything it touches gets owned by root.
Problem: this is done at the docker daemon level and affects all containers… what a mess.
Best Solution: use a Dockerfile to 1) delete the user in the image, 2) add a mapping from the host user’s UID/GID to the relevant user in the container, 3) rebuild the image.
Problem: I don’t quite understand everything that script is doing. And… What.A.Royal.Pain.
Alternatively, there’s podman which seems made specifically to address some of these issues (user namespace support, no daemon running as root), but I’m not as familiar with its solutions.
Plus all of this is attempting to address just the permissions aspect. We haven’t even touched on SELinux yet..
Right now I’m seeing ugly options:
Accept the waste of disk space and just use pts with a docker volume. No permissions issues, but duplication of installed tests taking up many GBs.
Ditch the local pts installation/tests, and use docker pts exclusively. Convenient, but there are several tests which cannot run in docker as they require a graphical environment.
Ditch the pts docker image and use the local pts only. No more permissions issues, but docker is useful for ensuring standard testing environments.
Let docker mess up permissions and selinux context and then run chown and restorconf
Since I don’t run pts often and I prioritize saving all that disk space, I’m thinking about the ugly last option…
Whats the image you are using anyways? Most images have environment variables to set the user and group. Some images force that group on the directory on start, others fail miserably when they dont do that and they end up not having access to it.