woodpecker: `2.4.1` backend docker run error `cannot create /root/.netrc: Permission denied`

Component

server, agent

Describe the bug

labels: # https://woodpecker-ci.org/docs/usage/workflow-syntax#labels
  backend: docker
  platform: linux/amd64

steps:
  python-poetry-gcc:
    image: fnndsc/python-poetry:1.7.1
    pull: false
    commands:
      - whoami
      - id

will be error as

/bin/sh: 3: cannot create /root/.netrc: Permission denied

but if use woodpecker 2.4.0 can run and print

+ whoami
mambauser
+ id
uid=1000(mambauser) gid=1000(mambauser) groups=1000(mambauser)

System Info

## woodpecker v2.4.1
labels: # https://woodpecker-ci.org/docs/usage/workflow-syntax#labels
  backend: docker
  platform: linux/amd64

steps:
  python-poetry-gcc:
    image: fnndsc/python-poetry:1.7.1
    pull: false
    commands:
      - whoami
      - id

Additional context

beacuse fnndsc/python-poetry:1.7.1 image not use root

  • For security, the python build file and the permission to run the cache are isolated

Validations

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 16 (10 by maintainers)

Most upvoted comments

See https://github.com/woodpecker-ci/woodpecker/blob/main/pipeline/backend/common/script.go#L31

Why do we hard-code HOME=/root while we don’t enforce that the container user is root? Either we don’t hard-code HOME or we set --user=root if we start step containers. Or am I missing something?

As @Hentioe said already setting HOME=/home/<container-user> manually works, however keep in mind you have to set it in the commands section via export HOME=/home/<container-user>, using the step environment option doesn’t work.

@woodpecker-ci/maintainers do you have a preferred way? I tend to drop the hard-coded HOME env var, but not sure about side effects.

on distroless/scratch

There is no shell.

$HOME is not set by the container

What if I run container as user and group 12345 (suppose, there is no such user/group)? I guess, container works under arbitrary user or not. The same with HOME.


If HOME is not set, we probably could set it to workspace root (/woodpecker).

@qwerty287 thanks for the suggestion but doesn’t seem to work for me, will adapt the image i use for now.

3.x.x. because we’ll release 3.0.0 next.

since the milestones changed, is that issue planed for 2.x.x or 3.x.x?

This is probably because Woodpecker incorrectly modified some environment variables when starting the container, causing the user executed in the container to not match the HOME variable. This also caused other related failures on my side, and I had to manually set the HOME variable.

Experiencing this issue as well after upgrading from 1.0.0 to 2.4.1. Reverting back to 2.4.0 did not fix it.

My docker environment is alpine 3.19