Copy Files from External URLs Into a Container With Dockerfile

This post will show how to copy files from an external URL directly into a Docker container using a Dockerfile.

Building Docker images with a Dockerfile is the most common method to build and reuse images. When building images, sometimes there is a need to download files from the external website (URL) directory into the container.


With the Docker ADD statement, we can download files directly into the container from an external site and essentially copy them.

Note: ADD and COPY statements are not the same. Read more in this post.

In the following Dockerfile, we use the ADD statement to download PowerShell 7 latest build directly into the container.


FROM ubuntu
RUN apt-get update
RUN mkdir downloads
ADD /downloads