Author: Brandon Pearman

The views expressed here are mine alone and do not reflect the view of my employer.

Every time you run docker build, the client (where your cli is) sends a new build context (the files you use to build the image) to the Docker Daemon/Server (where the building happens). The Daemon/Server can exist locally or it can exist over a network. Taking more files to the Daemon/Server increases the load and time to archive and send. Try avoid adding files which are not needed to build your image eg dist, bin, packages, node_modules

When you build an image and the Dockerfile has an ADD . or COPY . it may include unnecessary files eg .git or privatekeys. This may lead to exposing secrets through your image.

? matches a single character. eg to ignore files with a single character difference:


* matches and number of characters. eg to ignore any file name with extension md:


** matches and number of directories eg to ignore md files in any directory


/ matches a specific directory eg to ignore a directory


! Sets an exception eg to ignore all md files, except all which start with important, except

# will be ignored because it comes after the exception (its an exception to the exception)

Here are some examples of common ignores:


# ignore build files

# ignore visual studio files

# ignore git files

# ignore docker files

Check out these links for more info:

My Docker Samples