docker 文件 pip 安装在本地

问题描述 投票:0回答:1

这是我的 docker 文件:

WORKDIR /scan

RUN pip install pymongo
RUN pip install netmiko
RUN pip install pyats[full]
ENV Testbed=
ENV arr=
# ENV device=
# ENV id=

COPY . /scan
ENTRYPOINT ["python3", "main.py"]

我想在本地 pip 安装这个特定的软件包,就像从 tar 文件一样。我想在没有任何互联网的情况下构建图像,所以这就是为什么我需要它在本地,以便 pip 将从本地而不是从互联网获取它们。 我只是想澄清一下,当我 pip 安装要求时,它无论如何都会连接到互联网,我已经尝试过了。

python docker image pip internet-explorer-11
1个回答
0
投票

您需要 dockerfiles 中的基础镜像:

# Set the base image
FROM python:3.8

# Set the working directory
WORKDIR /scan

# Copy the local tar files into the image
COPY your_package1.tar.gz your_package2.tar.gz /tmp/

# Install packages from local tar files
RUN pip install /tmp/your_package1.tar.gz && \
    pip install /tmp/your_package2.tar.gz

# Set environment variables if needed
ENV Testbed=
ENV arr=

# Copy the rest of your application files
COPY . /scan

# Specify the entry point
ENTRYPOINT ["python3", "main.py"]
© www.soinside.com 2019 - 2024. All rights reserved.