Dockerfile -使用个人令牌从私有github repo安装pip 3

bmvo0sr5  于 2023-03-01  发布在  Docker
关注(0)|答案(2)|浏览(109)

我正在为我的python代码创建一个docker映像。

pip3 install git+https://$GITHUB_PERSONAL_ACCESS_TOKEN@github.com/<PATH_TO_REPO>@dev --no-cache-dir --force-reinstall

在dockerfile中。当我运行dockerbuild命令时,我得到以下错误

Running command git clone --filter=blob:none --quiet 'https://****@github.com/<PATH_TO_REPO>.git' /tmp/pip-req-build-cxx5g22f
  fatal: could not read Password for 'https://***@github.com': No such device or address
  error: subprocess-exited-with-error

我正在使用GitHub操作运行Docker构建,并在构建参数中传递GITHUB_PERSONAL_ACCESS_TOKEN
请帮帮忙

h43kikqp

h43kikqp1#

如果它是“个人访问令牌”(PAT)而不是OAuth-Token,则必须指定您的用户名,例如

pip3 install git+https://username:$GITHUB_PERSONAL_ACCESS_TOKEN@github.com/<PATH_TO_REPO>@dev --no-cache-dir --force-reinstall

username替换为PAT所属的GitHub用户名。

ar7v8xwq

ar7v8xwq2#

这起作用-〉pip3 install git+https://oauth2:$GITHUB_PERSONAL_ACCESS_TOKEN@github.com/<PATH_TO_REPO>@dev --no-cache-dir --force-reinstall

相关问题