A
A
Alexey Nikolaev2019-09-05 22:08:16
Docker
Alexey Nikolaev, 2019-09-05 22:08:16

Why doesn't Docker cache all commands?

Goodnight.
Usually, most commands when rebuilding an image use the cache and are executed instantly. However, some (longest ones) are not cached and are stubbornly executed again from scratch. For example, here it is:

# Gems and bundle
RUN cd /app/ \
    && bundle config git.allow_insecure true \
    && bundle config build.nokogiri --use-system-libraries \
    && bundle install --without development test \
    && apt-get purge -y \
      git \
      openssh-client \
      make \
      g++ \
      libxml2-dev \
      libxslt1-dev \
      libmagickwand-dev \
      libmariadbclient-dev \
      libsqlite3-dev \
      postgresql-server-dev-9.6 \
      libjpeg-dev \
      libpng-dev \
      libtiff-dev \
      libwebp-dev \
    && rm -rf /var/lib/apt/lists/* \
    && rm -rf /root/.ssh /tmp/* /var/tmp/*

I would really like that when rebuilding, if nothing in the command has changed, Docker also takes the result of executing this command from the cache.
Why are some commands not cached, and how to make sure that they are cached?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Karasik, 2019-09-06
@vitaly_il1

Share the weight of the Dockerfile, or just view it yourself. If at some stage there were changes, then all subsequent caches are not used.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question