pip doesn't work in docker containers
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 1.4k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 24
Description
Describe 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction in .github/workflows/django.yml and inspect the reported HOME, /github ownership, and /etc/passwd values inside the job container. Run pip cache dir to confirm the failure; done means pip cache commands work without the cache-disabled error while the container's home configuration remains consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100