Security around Docker commands
We will shortly be exploring the build process and how we can harden this from a security perspective. In order to do this, however, we will first dig into some of the commands we will use in a little more detail so we know which ones are safe to use, and which pose a potential threat. Let's start by looking at the COPY
and ADD
commands.
COPY versus ADD – what's the story?
When you come to build an image, you will want to copy files from the host over to it. Typically, there are two methods for doing this. If you've done any research online, you may have seen comments along the lines of "don't use the ADD
command." So why is this?
The ADD
command allows us to recursively copy files over to the image, much like a cp -r
command might do in Linux if we also piped it through zip
when necessary. In short, it expands archive files and creates any directories that don't exist on the target.
The input to...