-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Containers: overriding HOME environment variable with mismatching /etc/passwd home causes issues #1146
Comments
I've encountered this issue when two different workflows have executed on the same runner, but with containers running as different users. Files end up in the home directory that are owned by different users, resulting in permission denied errors. This can happen when a container is explicitly executed as a different user (ex: The following will run as root, and create a file in the home directory
The following will do the same as above, but run as the
We've come to the conclusion that the safest course of action is to try to run all containers as the root user, but this can be challenging when some software packages behave differently when running as root (ex: npm version 6 won't execute lifecycle scripts when run as root), while others refuse to run at all (ex: postgresql's pg_ctl refuses to run as root). |
I've encountered this issue when I use ssh in container
or
After run above command in a container job, ssh client command still get error (Host key verification failed.), because ssh using Insteads, I've run that command with |
This is actually a pretty annoying issue, e.g. installing binaries into /root (as suggested by the Github Actions docs we should base our image of a Debian distro). Which has $HOME mapped to Whilst in the container context home turns out to be There's a lot of install scripts that contain E.g. https://raw.githubusercontent.com/aws-cloudformation/cloudformation-guard/main/install-guard.sh
|
It looks like this also affects tool cache directories, as I just had a build fail in Error in
When the container was created, the tool cache directory (among many others) is mounted in as a volume:
I imagine that this issue could manifest in many different ways. |
Hi everyone, To help you with the workaround, I will provide more context to this issue and close it in favour of #863. We are aware of the permissions problem illustrated by issue #434. The runner will mount docker volumes as you described above. Files you created inside this docker container will be owned by the corresponding user on your host machine, so if you created a file as a root user inside the mounted volume inside the container, it will be owned by the root outside of it. More generally, if you have a user with UID 1000 (let's call it user That being said, we are aware of that problem and it is in our backlog. For updates on this issue please refer to the issues I have linked. Since we have this issue linked as well, it won't be hard for us to find it when we start testing the fix. I am sorry this issue is bothering you and I hope the explanation above helped a bit. |
GitHub Actions runner currently seems to set container
HOME
environment variable to/github/home
. Unfortunately, this is different from what the home directory is set to in the container's/etc/passwd
. For example, if the container is run asroot
, the home directory in/etc/passwd
is usually/root
.This mismatch causes some unexpected issues like making caching more difficult. When caching Java M2 dependencies for example, the following does not work:
This is because the Java
user.home
property is set to whatever is in/etc/passwd
.Would it be possible to have the runner not change
HOME
by default?On a related note, it would be really nice if the GitHub runner's parameters to docker containers were documented clearly somewhere.
The text was updated successfully, but these errors were encountered: