我的docker文件的开头如下,我经常更改后面的内容,但从不更改这部分,但运行需要一段时间,特别是RUN apt-get -y install npm
,我可以以某种方式缓存包下载吗?我查看了 docker 缓存,但我不认为这就是它的作用?
FROM ubuntu:20.04
RUN apt-get -y update
RUN apt-get -y install ruby
RUN apt-get -y install ruby-dev
RUN apt-get -y install gcc
RUN apt-get -y install make
RUN gem install compass
RUN apt-get -y install nodejs
RUN apt-get -y install npm
RUN apt-get -y install git
Run Code Online (Sandbox Code Playgroud)
kda*_*ria 23
这会将 apt-get 包存储在 docker 缓存中,因此不需要重新下载它们。您需要使用 buildkit。
# syntax=docker/dockerfile:1.3.1
FROM ubuntu
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
--mount=target=/var/cache/apt,type=cache,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean \
&& apt-get update \
&& apt-get -y --no-install-recommends install \
ruby ruby-dev gcc
Run Code Online (Sandbox Code Playgroud)
请参阅此文档了解更多详细信息。
归档时间: |
|
查看次数: |
12586 次 |
最近记录: |