checkout: Error: EACCES: permission denied in container on self hosted Linux runner
In an effort to checkout a repo within a container that’s being self hosted on a Linux VM running Ubuntu 20.04 as follows:
name: OS Build
# Controls when the workflow will run
on:
push:
paths-ignore:
- "Dockerfile"
- ".github/workflows/docker_build.yml"
- README.md
pull_request:
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: camis-build-p01
container:
image: ghcr.io/sensoftinc/imx8mp_yocto_build_environment:1.0.0
options: -u docker
With the image Docker file defined as:
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt update && apt upgrade -y && apt install ca-certificates -y && apt install wget locales -y && locale-gen en_US.UTF-8
RUN apt install sudo
RUN apt install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev util-linux srecord -y
RUN apt install xterm sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils \
libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff curl lzop asciidoc -y
RUN apt install cpio python python3-pip python3-pexpect xz-utils debianutils iputils-ping \
python3-git python3-jinja2 libegl1-mesa xsltproc fop dblatex xmlto pylint3 -y
RUN apt install u-boot-tools -y
RUN groupadd -r docker && useradd -r -g docker -ms /bin/bash -u 1001 docker && adduser docker sudo
I get the following error:
/usr/bin/docker exec 5b033937ed15061a8f606fa5f3805d0794caf9e04e3c12576fda15d25bde22ab sh -c "cat /etc/*release | grep ^ID"
node:internal/fs/utils:344
throw err;
^
Error: EACCES: permission denied, open '/__w/_temp/_runner_file_commands/save_state_c7001c04-a974-4f62-8e53-a488[14](https://github.com/SensoftInc/imx8mp_yocto/actions/runs/3490287639/jobs/5841522655#step:3:15)7475c5'
at Object.openSync (node:fs:585:3)
at Object.writeFileSync (node:fs:2[15](https://github.com/SensoftInc/imx8mp_yocto/actions/runs/3490287639/jobs/5841522655#step:3:16)3:35)
at Object.appendFileSync (node:fs:2215:6)
at Object.issueFileCommand (/__w/_actions/actions/checkout/v3/dist/index.js:2293:8)
at Object.saveState (/__w/_actions/actions/checkout/v3/dist/index.js:1[18](https://github.com/SensoftInc/imx8mp_yocto/actions/runs/3490287639/jobs/5841522655#step:3:19)73:31)
at Object.153 (/__w/_actions/actions/checkout/v3/dist/index.js:4044:10)
at __webpack_require__ (/__w/_actions/actions/checkout/v3/dist/index.js:[22](https://github.com/SensoftInc/imx8mp_yocto/actions/runs/3490287639/jobs/5841522655#step:3:23):30)
at Object.[28](https://github.com/SensoftInc/imx8mp_yocto/actions/runs/3490287639/jobs/5841522655#step:3:29)7 (/__w/_actions/actions/checkout/v3/dist/index.js:7013:34)
at __webpack_require__ (/__w/_actions/actions/checkout/v3/dist/index.js:22:[30](https://github.com/SensoftInc/imx8mp_yocto/actions/runs/3490287639/jobs/5841522655#step:3:31))
at Object.853 (/__w/_actions/actions/checkout/v3/dist/index.js:[31](https://github.com/SensoftInc/imx8mp_yocto/actions/runs/3490287639/jobs/5841522655#step:3:32)801:36) {
errno: -13,
syscall: 'open',
code: 'EACCES',
path: '/__w/_temp/_runner_file_commands/save_state_c7001c04-a974-4f62-8e53-a488147475c5'
}
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 20
- Comments: 26
Commits related to this issue
- adding -u root to fix github action error (https://github.com/actions/checkout/issues/1014) — committed to JPenuchot/ctbench by JPenuchot 4 years ago
- Workaround GitHub Actions limits Due to this [1] it seems impossible to run the container as an unprivileged user, so we override with root. [1] https://github.com/actions/checkout/issues/1014 — committed to mmul-it/kpa-mmul by rascasoft 3 years ago
- Workaround GitHub Actions limits Due to this [1] it seems impossible to run the container as an unprivileged user, so we override with root. [1] https://github.com/actions/checkout/issues/1014 — committed to mmul-it/kpa by rascasoft 3 years ago
- Workaround GitHub Actions limits Due to this [1] it seems impossible to run the container as an unprivileged user, so we override with root. [1] https://github.com/actions/checkout/issues/1014 — committed to mmul-it/kpa_generator by rascasoft 3 years ago
- Workaround GitHub Actions limits Due to this [1] it seems impossible to run the container as an unprivileged user, so we override with root. [1] https://github.com/actions/checkout/issues/1014 — committed to mmul-it/kpa_generator by rascasoft 3 years ago
- Update visual regression According to https://github.com/actions/checkout/issues/1014#issuecomment-1369355566 — committed to Vonage/vivid-3 by YonatanKra 3 years ago
- Patch: use `root` user according to actions/checkout#1014 — committed to HuangFuSL/HuangFuSL.github.io by HuangFuSL 3 years ago
- Fix: deployment fail (#191) * Fix: override `WORKDIR` command * Patch: disabled if condition for testing * Patch: disable preceding workflow * Patch: add verbose option to check path * Pa... — committed to HuangFuSL/HuangFuSL.github.io by HuangFuSL 3 years ago
- update ci https://github.com/actions/checkout/issues/1014 — committed to pyg-team/pytorch_geometric by akihironitta 3 years ago
- Switched to root user to workaround permission errors due to actions/checkout/issues/1014 — committed to jammont/isofit by jammont 3 years ago
- Use root for GitHub Actions container This is needed to solve this bug [1]. [1] https://github.com/actions/checkout/issues/1014 — committed to mmul-it/kubelab by rascasoft 3 years ago
- Use root for GitHub Actions container This is needed to solve this bug [1]. [1] https://github.com/actions/checkout/issues/1014 — committed to mmul-it/tfs_generator by rascasoft 3 years ago
- Use root for GitHub Actions container This is needed to solve this bug [1]. [1] https://github.com/actions/checkout/issues/1014 — committed to mmul-it/kubelab by rascasoft 3 years ago
- Use root for GitHub Actions container This is needed to solve this bug [1]. [1] https://github.com/actions/checkout/issues/1014 — committed to mmul-it/tfs_generator by rascasoft 3 years ago
- Maybe need this fix for https://github.com/actions/checkout/issues/1014 — committed to wri/gfw_forest_loss_geotrellis by danscales 3 years ago
- Maybe need this fix for https://github.com/actions/checkout/issues/1014 — committed to wri/gfw_forest_loss_geotrellis by danscales 3 years ago
- Adding /__w directory to tools image This (in theory) will allow running GHA in container, without root see https://github.com/actions/checkout/issues/1014 — committed to paritytech/scripts by mutantcornholio 2 years ago
- ci: temporarily run upload job as root This commit modifies the upload job in the `build.yaml` GitHub Action to temporarily run as root. This change addresses permission issues caused by a bug in Git... — committed to livepeer/go-livepeer by rickstaa 2 years ago
- Try another WA for GH Actions https://github.com/actions/checkout/issues/1014 — committed to ltowarek/dust-mite by ltowarek 2 years ago
- test: must be running as root inside container https://github.com/actions/checkout/issues/1014 — committed to ahwayakchih/crx3 by ahwayakchih 2 years ago
I think https://github.com/actions/checkout/issues/956 has workarounds, so I think this issue can be closed.
The workaround that I used was to “override the default container user and use ‘root’”:
Today GitHub only supports root users on the container, so we likely will only get workarounds unless/until that changes.
Yes, that’s what I am doing it now. But ideally, I want to run the unit tests in the container by a regular user. Because there is a bit of difference between running the program by a regular user and the root user in my case.
Hi all,
I am not sure if this is still a valid place to comment, but I got similar errors and I want to give you some feedback and workaround.
The initial idea is to not use root, so we wanted
non-rootaccess to some host folders inside our container.The solution mentioned earlier
RUN mkdir -m 1777 /__wdoes not work (anymore) as of today.Runner version
[v2.315.0]and[v2.316.0]were tested here on GHE 3.12.Another hint I need to give: https://docs.github.com/en/enterprise-server@3.12/actions/creating-actions/dockerfile-support-for-github-actions#user
Github still suggests to use root.
Anyways, this is the workaround for
non-rootaccess inside container.--userns=hostoption, see: https://docs.docker.com/engine/security/userns-remap/#disable-namespace-remapping-for-a-containerRUN useradd runner_1000 -m -u 1000 -s /bin/bashfor the UID 1000 to exist inside the docker container.This made it work. The cleanup step was not throwing access errors anymore.
⚠️ Please do know that you might mitigate some security features and you might be exposing too many files and access rights.
I wish that Github would fix the access to the host folders that are anyways used inside the container…
Best regards
I have a self hosted actions-runner on Ubuntu 20.04. It runs without sudo. It was having this problem.
Adding this “cleanup old checkout” step is working for me.
I have my own workaround - nonroot:
# add to dockerfile RUN mkdir -m 1777 /__w
The easiest way to workaround this is to go back to actions/upload-artifact@v2 not ideal although but it works
Adding my 2 cents as well, we want to specifically not run as root so the workaround doesn’t work in our case. We figured any other way around this?
If you have control of the image, use UID and GID 1001 when setting up your non-root user in your Dockerfile. This worked for me:
Just to add,
options: --user rootdoes not appear to be a recognized option when using GitHub Action Runner Controller for self-hosting inkubernetesmode. (It is recognized in dind mode, which does not respect resource limits).A better solution would be great.
I get this when using a larger runner as well (following https://docs.github.com/en/actions/using-github-hosted-runners/about-larger-runners/running-jobs-on-larger-runners)