pip doesn't work in docker containers
See original GitHub issueDescribe the bug
The runner changes HOME
variable for job containers, but the home directory remains owned by someone else, and /etc/passwd
does not reflect the change. This causes all kinds of side effects.
I had another case. I tried to run sshd
in a container, and it didn’t work because home directory in /etc/passwd
was still /root
, so I had to:
apk add gawk
awk -i inplace -F: '
$1 == "root" {print $1 ":" $2 ":" $3 ":" $4 ":" $5 ":/github/home:" $7}
$1 != "root" {print $0}
' /etc/passwd
Okay, making containers communicate over ssh
was probably a silly idea. This was my first time configuring a workflow. But still, changing HOME
breaks some software.
To Reproduce Steps to reproduce the behavior:
.github/workflows/django.yml
:
...
name: Django workflow
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
container: python:3.5-alpine3.12
steps:
- run: apk add expect && unbuffer sh -euxc '
whoami
&& set
&& ls -Al `dirname "$HOME"`
&& cat /etc/passwd
&& pip cache dir
&& exit 1
'
Output:
+ whoami
root
+ set
HOME='/github/home'
+ ls -Al /github
total 8
drwxr-xr-x 2 1001 116 4096 Aug 9 13:14 home
drwxr-xr-x 2 1001 116 4096 Aug 9 13:14 workflow
+ cat /etc/passwd
root:x:0:0:root:/root:/bin/ash
+ pip cache dir
WARNING: The directory '/github/home/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
ERROR: pip cache commands can not function since cache is disabled.
Expected behavior
pip
finishes successfully. Ideally, HOME
shouldn’t be changed. At least provide some recommendations, or explain your reasoning.
Runner Version and Platform
The one running on GitHub.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
Hello! Any updates on this issue? I didn’t workout to configure pip dependency caching because of this. I have a container with volume for pip cache directory, and it is saved in GH actions cache because of the following error
@rdisipio I guess it needs
chown
after all: