简体   繁体   English

将私有 PyPi 存储库导入 Docker 容器

[英]Import private PyPi Repository into Docker container

I'm trying to Dockerize a Python application that uses a package from a private PyPi repository.我正在尝试对使用来自私有 PyPi 存储库的 package 的 Python 应用程序进行 Docker 化。 The problem is, none of the guides I'm finding online seem to work.问题是,我在网上找到的指南似乎都不起作用。 I'd imagine such a thing is probably used fairly widely so it can't be that difficult to do, but I seem to be having trouble.我想这样的事情可能被广泛使用,所以做起来并不难,但我似乎遇到了麻烦。

I am able to run this application through a regular development environment (ie command line) so the repository is working fine and connecting to it works normally.我能够通过常规开发环境(即命令行)运行此应用程序,因此存储库工作正常并且连接到它正常工作。 I just can't get Docker to recognize it.我只是无法让 Docker 识别它。 I found this guide on Medium which claims to do what I want;在 Medium 上找到了这个指南,它声称可以做我想做的事; according to my sysadmin I shouldn't need SSH so I ignored that part but I imported my pip.conf file using the steps in that guide.根据我的系统管理员,我不应该需要 SSH 所以我忽略了该部分,但我使用该指南中的步骤导入了我的 pip.conf 文件。 I was able to confirm that the pip.conf was being imported using the required flag as suggested in that article, except that it's failing when I try to pip install.我能够确认 pip.conf 是使用该文章中建议的所需标志导入的,但当我尝试安装 pip 时它失败了。 Here's my docker command and dockerfile, please help.这是我的 docker 命令和 dockerfile,请帮忙。

HOME?=`echo $HOME`

my-make-command:
    DOCKER_BUILDKIT=1 && \
    docker build --secret id=pip.conf,src=${HOME}/.pip/pip.conf -t tag .
# syntax=docker/dockerfile:1.0.0-experimental

FROM python:3.8-alpine

COPY * .

RUN --mount=type=secret,id=pip.conf,required pip install -r requirements.txt
CMD ["python3", "app.py"]

My guess would be that you need to be using the company's internet / VPN to access your private PyPi repository.我的猜测是您需要使用公司的互联网/VPN 来访问您的私有 PyPi 存储库。

If so, maybe you could try adding the --network host param to your docker build command.如果是这样,也许您可以尝试将--network host参数添加到您的 docker 构建命令中。

You may need to restart Docker after connecting to the VPN.连接VPN后可能需要重启Docker。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM