Docker - 从私有gitlab仓库中提取库

时间:2018-05-16 18:24:26

标签: docker gitlab

我试图创建一个python的Docker镜像,并添加一个由我公司创建并托管在gitlab上的python库(非公开)。

我的Docker文件是:

FROM continuumio/anaconda3

RUN apt-get update
RUN apt-get install -y curl

RUN pip install --upgrade pip

RUN pip install https://gitlab.criteois.com/ax-analytics/CriteoPy/repository/pep_8/archive.zip

WORKDIR home

CMD ["python3", "main.py"]

看起来步骤5/7失败了:

Step 5/7 : RUN pip install https://gitlab.criteois.com/ax-analytics/CriteoPy/repository/pep_8/archive.zip
 ---> Running in 8f04623ef493
Collecting https://gitlab.criteois.com/ax-analytics/CriteoPy/repository/pep_8/archive.zip
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f8f926ae0f0>: Failed to establish a new connection: [Errno -5] No address associated with hostname',)': /ax-analytics/CriteoPy/repository/pep_8/archive.zip

The command '/bin/sh -c pip install https://gitlab.criteois.com/ax-analytics/CriteoPy/repository/pep_8/archive.zip' returned a non-zero code: 1

我怀疑由于主机上的docker之间的联网而导致一些权限问题,因为我在运行时

cbslax@cbslax-desktop:~/Documents/DockerCriteoPy$ curl https://gitlab.criteois.com/ax-analytics/CriteoPy/repository/pep_8/archive.zip --output CriteoPy-Pep-8.zip

我可以在没有任何输入的情况下下载库

1 个答案:

答案 0 :(得分:1)

尝试在构建命令中添加 - 网络主机参数。不推荐使用,但您可以查看Docker默认创建的默认网桥网络是否存在问题。

实施例

$ docker build <other args> --network host .

使用--network host参数,基本上你告诉Docker使用你的本地网络而不是它创建的默认网桥。