Using COPY from within a RUN

To reduce image layers its common for docker images to combine multiple commands in a single RUN. eg. https://github.com/docker-library/redis/blob/9db6cc1645465f134d03584dbbbd962ce822479a/3.2/alpine/Dockerfile .

It’s also common to CURL or WGET a zip file from an external location.

I would like to add a zip file from within a RUN command in the same way the COPY command works.

To explain further, I have a large local zip file and I don’t want to use COPY because that adds a new layer, increasing my image size. I want to do whatever COPY does but from within a RUN command. I can then chain my commands together resulting in 1 layer rather than 2.

What does COPY actually do?

From the Dockerfile reference, COPY does the following:

The COPY instruction copies new files or directories from
and adds them to the filesystem of the container at the path .

I know what copy does, but what is it actually doing under the covers? Your reply doesn’t help answer my question.