Skip to content

Instantly share code, notes, and snippets.

@AkihiroSuda
Created July 24, 2018 07:11
Show Gist options
  • Save AkihiroSuda/978c94bc2297867ba60d8cba5a893def to your computer and use it in GitHub Desktop.
Save AkihiroSuda/978c94bc2297867ba60d8cba5a893def to your computer and use it in GitHub Desktop.
Docker v18.06 `RUN --mount=type=cache` example (keep /var/cache/apt)
# syntax = tonistiigi/dockerfile:runmount20180618
#
# `RUN --mount` example. Requires Docker v18.06 with `DOCKER_BUILDKIT=1`.
#
# `RUN --mount=... apt install <PKGS>` should finish immediately even when some packages are added to <PKGS> or built with `docker build --no-cache`.
FROM ubuntu
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked --mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && apt install -y gcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment