I’m experimenting with the docker 17.05.0-ce-rc1 and trying out multi stage builds.
One thing I’ve noticed is that the previous stages become dangling, and thus docker image prune
will remove those build steps. I understand sometimes this may be desired if you are trying to clean up much needed disk space, and don’t plan on rebuilding that image anytime soon… However I’d like to keep that cache around. Any idea how I can (easily) make it not dangling? Right now I can only think of a manual process where I try to determine the sha of a stage and tag it. But I do not think that a good solution of many reasons.
For example
FROM alpine:3.5 AS stage1
RUN apk --no-cache add python openssl
RUN apk --no-cache add py-virtualenv gcc python-dev openssl-dev libffi-dev musl-dev
RUN virtualenv /opt/certbot && \
. /opt/certbot/bin/activate && \
pip install certbot
FROM alpine:3.5
RUN apk --no-cache add python openssl
COPY --from=stage1 /opt/certbot /opt/certbot
The last two command in stage1 will be marked as dangling.