mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-11-01 15:19:24 +00:00
This adds a helper which monitors the Docker event stream and, when it receives an image delete event, queues a call to `fstrim /var/lib/docker` to trigger a space reclamation. Previously we would rely on a cron job running every 15 minutes. Signed-off-by: David Scott <dave.scott@docker.com>
27 lines
882 B
Docker
27 lines
882 B
Docker
# We need the `fstrim` binary:
|
|
FROM linuxkit/alpine:630ee558e4869672fae230c78364e367b8ea67a9 AS mirror
|
|
RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/
|
|
RUN apk add --no-cache --initdb -p /out \
|
|
alpine-baselayout \
|
|
busybox \
|
|
util-linux
|
|
|
|
# Remove apk residuals
|
|
RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache
|
|
|
|
# We also need the Go binary which calls it:
|
|
RUN apk add --no-cache go musl-dev
|
|
ENV GOPATH=/go PATH=$PATH:/go/bin
|
|
|
|
COPY . /go/src/trim-after-delete
|
|
RUN go-compile.sh /go/src/trim-after-delete
|
|
|
|
FROM scratch
|
|
ENTRYPOINT []
|
|
CMD []
|
|
WORKDIR /
|
|
COPY --from=mirror /out/ /
|
|
COPY --from=mirror /go/bin/trim-after-delete /usr/bin/trim-after-delete
|
|
CMD ["/usr/bin/trim-after-delete", "--", "/sbin/fstrim", "/var/lib/docker"]
|
|
LABEL org.mobyproject.config='{"binds": ["/var/run:/var/run", "/var/lib/docker:/var/lib/docker"], "capabilities": ["CAP_SYS_ADMIN"]}'
|