What is Build Cache in Docker?
What is Build Cache in Docker?
The Docker build cache is a mechanism that allows Docker to reuse previously created image layers during the build process. This feature significantly speeds up the build process by avoiding the need to re-execute commands that have not changed since the last build. Here’s a detailed explanation:
RUN
, COPY
, ADD
) creates a new layer.COPY
command and all commands that follow it in the Dockerfile.Consider the following Dockerfile:
FROM node:14
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
RUN yarn build
CMD ["node", "index.js"]
In this example:
COPY package.json yarn.lock ./
and RUN yarn install
commands are likely...junior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào