在dockerfiles中使用哪个Python变体作为基本映像? [英] Which Python variant to use as a base image in dockerfiles?
问题描述
我正在使用Python_onbuild作为dockerfile中的基础映像,如下所示。但是,每当我在源文件中进行更改时,都会通过使高速缓存无效来重复执行我的命令。
I am using Python_onbuild as a base image in the dockerfile as below. However, it is causing my commands to be repeated by invalidating the cache whenever I make a change in the source file.
FROM python:2.7.13-onbuild
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
RUN echo "Test Cache"
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install --assume-yes apt-utils
RUN apt-get update && apt-get install -y curl
RUN apt-get update && apt-get install -y unzip
RUN curl -o - url
构建日志:
Sending build context to Docker daemon 239.1kB
Step 1/6 : FROM python:2.7.13-onbuild
# Executing 3 build triggers...
Step 1/1 : COPY requirements.txt /usr/src/app/
---> Using cache
Step 1/1 : RUN pip install --no-cache-dir -r requirements.txt
---> Using cache
Step 1/1 : COPY . /usr/src/app
---> 13e927036649
复制的第三步(步骤1/1:COPY。/ usr / src / app)
每当我对工作目录中的任何文件进行更改时,都会重复其余命令。我认为这是来自基本映像的ONBUILD命令。如果那是真的,那么在这种情况下替代基本映像是什么?我应该使用Python:吗?
This 3rd step of copying (Step 1/1 : COPY . /usr/src/app)
is making the rest of the commands repeated whenever I make a change in any files in the working directory. I think this an ONBUILD command from the base image. If that true then what is the alternative base image in such situation? Should I use Python:?
我想要对需求安装以及复制过程进行更多控制,因为我必须下载一个我不想要的3.6GB文件每次我构建docker时都要重复一次。
I want more control on the requirement installation as as well as the copying process because I have to download a 3.6GB file which I do not want to repeat every time I build the docker.
注意:此特定的基本图像是由其他人选择的,而我是在一些现有工作的基础上构建的。
Note: This specific base image was chose by someone else and I am building on top of some existing work.
推荐答案
此 Dockerfile 。
如您所见,它基于 python:2.7
。因此,如果您不需要 ONBUILD
说明,只需直接使用此图像或适合您需求的图像即可:您可以在 Docker Hub上的python映像,并带有指向所有相应Dockerfile的链接。
The base image you're using is described in this Dockerfile.
As you can see, it's based on python:2.7
. So if you don't need the ONBUILD
instructions, just use this image directly or the one that can fit your needs: you can find a list on the python image on Docker Hub with links to all the corresponding Dockerfiles.
这篇关于在dockerfiles中使用哪个Python变体作为基本映像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!