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 fileand the permission to run thecacheare isolated
Validations
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Checked that the bug isn’t fixed in the
nextversion already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 16 (10 by maintainers)
See https://github.com/woodpecker-ci/woodpecker/blob/main/pipeline/backend/common/script.go#L31
Why do we hard-code
HOME=/rootwhile we don’t enforce that the container user is root? Either we don’t hard-codeHOMEor we set--user=rootif 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 thecommandssection viaexport HOME=/home/<container-user>, using the stepenvironmentoption doesn’t work.@woodpecker-ci/maintainers do you have a preferred way? I tend to drop the hard-coded
HOMEenv var, but not sure about side effects.There is no shell.
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 withHOME.If
HOMEis 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