docker - 在构建 Docker 镜像时使用来自私有(private) gitlab 存储库的 pip install

标签 docker ubuntu gitlab ssh-keys ssh-keygen

我正在尝试在 Ubuntu 机器上构建一个 docker 镜像,其中一个依赖项是
一个内部托管的 Gitlab 项目(它不在 GITLAB.COM 上托管)。
docker 文件是:

FROM  rayproject/ray:1.12.0-py39-cpu
RUN git config --global user.name <MY USER NAME>
RUN git config --global http.sslVerify false
COPY .ssh/id_rsa /home/ray/.ssh/id_rsa
RUN sudo chmod -R 777 ~/.ssh/*
RUN eval "$(ssh-agent -s)"
RUN eval `ssh-agent -s` && ssh-add $HOME/.ssh/id_rsa
RUN pip install git+https://gitlab.<EMPLOYERS DOMAIN>.com/xyz/my_project.git
我正在尝试使用以下命令构建 docker 文件:
docker build .
构建 docker 镜像时收到此错误消息:
Step 8/29 : RUN pip install git+https://gitlab.<EMPLOYERS DOMAIN>.com/xyz/my_project.git
 ---> Running in b9e11319c84d
Collecting git+https://gitlab.<EMPLOYERS DOMAIN>.com/xyz/my_project.git
  Cloning https://gitlab.<EMPLOYERS DOMAIN>.com/xyz/my_project.git to /tmp/pip-req-build-l1qklujg
  Running command git clone -q https://gitlab.<EMPLOYERS DOMAIN>.com/xyz/my_project.git /tmp/pip-req-build-l1qklujg
  fatal: could not read Username for 'https://gitlab.<EMPLOYERS DOMAIN>.com': No such device or address
WARNING: Discarding git+https://gitlab.<EMPLOYERS DOMAIN>.com/xyz/my_project.git. Command errored out with exit status 128: git clone -q https://gitlab.<EMPLOYERS DOMAIN>.com/xyz/my_project.git /tmp/pip-req-build-l1qklujg Check the logs for full command output.
ERROR: Command errored out with exit status 128: git clone -q https://gitlab.<EMPLOYERS DOMAIN>.com/xyz/my_project.git /tmp/pip-req-build-l1qklujg Check the logs for full command output.
但是,从我的机器上,我可以运行
pip install https://gitlab.<EMPLOYERS DOMAIN>.com/xyz/my_project.git
无需输入我的用户名/密码。
我不确定我的机器是否配置为使用 RSA key 登录内部 Gitlab。
构建 docker 镜像时如何安装包?

最佳答案

使用ssh而不是 https . IE。

RUN pip install git+ssh://gitlab.<EMPLOYERS DOMAIN>.com/xyz/my_project.git

关于docker - 在构建 Docker 镜像时使用来自私有(private) gitlab 存储库的 pip install,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72440280/

相关文章:

linux - 将目录中的文件数返回到 shell 脚本中的变量

linux - 在 ubuntu 上安装 semantic-UI(终端错误)

docker - GitLab 管道 Docker 构建卡在 apk 上

firebase - 在 Firebase 静态托管上托管 Docker 应用程序

python - 获取 python docker 容器以与 redis docker 容器交互

docker - 如何链接docker容器?

ubuntu - 无法让 nrepl 在 Emacs 中工作

mysql - 解决错误 : An error occurred while installing mysql2 (0. 4.5),Bundler 无法继续。确保 `gem install mysql2 -v ' 0.4。 5'`

docker - 包含 GitLab、docker 和 docker 私有(private)注册表的 CD

git - 将网络存储附加到 Gitlab 的 Docker 容器(ssh 问题)