Skip to content
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

Add an example of accessing the secrets file without root permissions #560

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/advanced/secrets.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ RUN --mount=type=secret,id=github_token \
cat /run/secrets/github_token
```

If you need access to the `secrets` file from a non-root user, you'll need to set the `uid` in the `--mount` argument:

```Dockerfile
#syntax=docker/dockerfile:1.2

FROM alpine

# Create non-root user
RUN addgroup -S newuser && adduser -u 1001 -S -g newuser newuser

# Run everything after as non-privileged user.
USER newuser

RUN --mount=type=secret,uid=1001,id=github_token \
cat /run/secrets/github_token
```

As you can see we have named our secret `github_token`. Here is the workflow you can use to expose this secret using
the [`secrets` input](../../README.md#inputs):

Expand Down