I have these commands in a Dockerfile:
RUN apt-get -y update #1
RUN apt-get -y install sudo #2
RUN sudo apt-get -y update #3
RUN sudo apt-get -y upgrade #4
RUN sudo apt-get install -y sqlite3 libsqlite3-dev #5
It looks as though Docker cannot cache line #3 or #4
Is there a way I can allow Docker to cache those results somehow? It's taking a minute or two to update/upgrade every time the image is built and I'd like to reduce this delay.
First thing You should avoid RUN apt-get upgrade or dist-upgrade, as many of the “essential” packages from the base images won't upgrade inside an unprivileged container. If a package contained in the base image is out-of-date, you should contact its maintainers.
I think you need to run apt-get update only once within the Dockerfile & Always combine RUN apt-get update with apt-get install in the same RUN statement like
RUN apt-get update && apt-get install -y \
sudo \
sqlite3 \
libsqlite3-dev
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.