我正在尝试在 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/