2 回答
TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超5個贊
關(guān)于尺寸,請確保您在使用時(shí)始終通過(您使用一次,但在其他情況下不使用)。同樣,結(jié)合使用并確保最后一步是清除緩存,使其永遠(yuǎn)不會在圖像層中凍結(jié),例如將三個單獨(dú)的 s替換為; 在單層中實(shí)現(xiàn)相同的效果,即不保留緩存。--no-cache-dirpipapkapkRUNRUN apk update && apk upgrade && apk add bash && rm -rf /var/cache/apk/*apk
例子:
FROM python:3.7-alpine
COPY requirements.pip ./requirements.pip
# Avoid pip cache, use consistent command line with other uses, and merge simple layers
RUN python3 -m pip install --upgrade --no-cache-dir pip && \
python3 -m pip install --upgrade --no-cache-dir setuptools
# Combine update and add into same layer, clear cache explicitly at end
RUN apk update && apk add --no-cache --virtual .build-deps gcc python3-dev musl-dev openssl-dev libffi-dev g++ && \
python3 -m pip install -r requirements.pip --no-cache-dir && \
apk --purge del .build-deps && rm -rf /var/cache/apk/*
不要指望它會做很多事情(您已經(jīng)--no-cache-dir在大型pip操作中使用過),但它確實(shí)有用。pandas是一個巨大的單體包,依賴于其他巨大的單體包;您可以在這里完成的工作是有限度的。
添加回答
舉報(bào)
