Skip to content

Commit

Permalink
Merge pull request #3017 from airtower-luna/apt-example-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
tonistiigi committed Aug 11, 2022
2 parents 2353487 + a577b86 commit e049134
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions frontend/dockerfile/docs/reference.md
Expand Up @@ -894,11 +894,18 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
# syntax=docker/dockerfile:1
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 \
--mount=type=cache,target=/var/lib/apt \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && apt-get --no-install-recommends install -y gcc
```

Apt needs exclusive access to its data, so the caches use the option
`sharing=locked`, which will make sure multiple parallel builds using
the same cache mount will wait for each other and not access the same
cache files at the same time. You could also use `sharing=private` if
you prefer to have each build create another cache directory in this
case.

### RUN --mount=type=tmpfs

This mount type allows mounting tmpfs in the build container.
Expand Down

0 comments on commit e049134

Please sign in to comment.