Run the job.container as the same user of the host VM by default
See original GitHub issueDescription
Run the containers as the same user running on the host (the VM) by default, or at least provide an option. The related docker option would be docker run --user "$(id -u):$(id -g)"
.
Containers job.container
runs as the container’s default user by default, which often is root. This causes some weird behaviors because the workspace
on the GitHub runner is mounted to the container, and no other user (other than the Runner user) has permission to write on it. This is what makes @actions/checkout fail when running on containers.
As Jenkins does, this should be made by default. Users who might want to run as a different user can still use the --user
docker option.
Workaround
jobs:
configure:
runs-on: ubuntu-latest
outputs:
uid_gid: ${{ steps.get-user.outputs.uid_gid }}
steps:
- id: get-user
run: echo "::set-output name=uid_gid::$(id -u):$(id -g)"
clone-and-install:
needs: configure
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/vscode/devcontainers/base:ubuntu
options: --user ${{ needs.configure.outputs.uid_gid }}
steps:
- uses: actions/checkout@v2
It’s even funny to have to do such a thing.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:42
- Comments:5
Top Results From Across the Web
Networking with standalone containers
Use user -defined bridge networks shows how to create and use your own custom bridge networks, to connect containers running on the same...
Read more >Isolate containers with a user namespace
For containers whose processes must run as the root user within the container, you can re-map this user to a less-privileged user on...
Read more >Configuring options to run your container
Go to the Create an instance template page. Go to Create an instance template. · In the Container section, select the Deploy a...
Read more >Containers on Compute Engine
Software containers are a convenient way to run your apps in multiple isolated user-space instances. You can run containers on Linux or Windows...
Read more >Define container jobs (YAML) - Azure Pipelines
Run pipeline jobs inside of a container. ... By default, jobs run on the host machine where the agent is installed.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This won’t work if you have a pool of self-hosted runners and jobs are dispatched by different runners. ID’s may mismatch.
@russellsch There are two options for you: Rootless Docker Podman, with podman.socket enabled. You may have to create a symlink for /usr/bin/docker to /usr/bin/podman.
Before rootless docker was available and podman supported interaction over a socket, I used parameter injection to inject --user for create, exec, and run commands.