Dockerfile: COPY/ADD and RUN with rm in a single layer

Viewed 236

I'd like to execute a COPY/ADD command and a subsequent RUN in a single layer, so that the added file doesn't bloat the final image size. Something in the lines of:

WORKDIR /opt/install

# START I want this in a single layer
COPY install.sh /opt/install
RUN ./install.sh && rm install.sh
# END

I know I may do it with a --squash argument upon build, but I'd like to know if there is any way to do it directly in the Dockerfile.

1 Answers
Related