【问题标题】:Dockerfile - pip3 install from private github repo using personal tokenDockerfile - pip3 使用个人令牌从私人 github 仓库安装
【发布时间】:2023-02-22 16:27:34
【问题描述】:

我正在为我的 python 代码创建一个 docker 图像。 要安装依赖项和要求,我有

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

在 Dockerfile 中。当我运行 docker build 命令时,出现以下错误

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 build 并在 build 参数中传递 GITHUB_PERSONAL_ACCESS_TOKEN

请帮忙

【问题讨论】:

    标签: docker github-actions


    【解决方案1】:

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

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

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

    【讨论】:

    • 谢谢你的回复。我可以试试这个,但问题是为什么 pip3 install git+https://$GITHUB_PERSONAL_ACCESS_TOKEN@github.com/&lt;PATH_TO_REPO&gt;@dev --no-cache-dir --force-reinstall 在 docker 环境中不工作。当我在 VM 中部署代码时,它可以工作。
    猜你喜欢
    • 2021-01-23
    • 2020-04-27
    • 2012-08-27
    • 2017-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多