In this post, we will show how to copy files and folders to a Docker container image using a Dockerfile.
When building Docker images we always have situations where we need to copy files or folders into a container and with a Dockerfile, we can also do it.
To copy files or folders to a container, we use the COPY statement that handles the process for us. We only need to provide a path to the source and destination, and Docker will copy the file.
In the following example, I am copying a folder called app, located in the same folder as my Dockerfile to a container. The destination is a folder called downloads that I created before.
RUN mkdir downloads
COPY app /downloads
To learn how to build a Dockerfile, visit the following post.