liveBook · Manning

Dockerignore

As explained in .NET in Action, Second Edition

.dockerignore is a Docker configuration file that specifies files and directories excluded from a build context.

.dockerignore controls which files and directories Docker excludes from the build context. This prevents local build artifacts from being copied into an image when a Dockerfile copies the current folder. section 13.3.1

Typical .NET exclusions

A .NET service can exclude /bin/, /obj/, and /.vscode/. These directories contain local build or editor artifacts that do not belong in the container image. section 13.3.1

Listing 13.3 Contents of .dockerignore
/bin/
/obj/
  
# Ignore any Visual Studio Code-specific artifacts    #1
/.vscode/

Inspect the complete .dockerignore example for the AsciiArtSvc service. section 13.3.1

How .NET in Action, Second Edition covers it

How deep it goes
Defines exclusion patterns and their purpose, but does not detail pattern-matching rules or Docker internals.
Examples
Uses /bin/, /obj/, and /.vscode/ exclusions for an AsciiArtSvc project.
What it assumes
Assumes familiarity with Dockerfiles, build contexts, and copying project files into images.
What you can do after
Operate/configure Docker builds by excluding unnecessary .NET and IDE artifacts from the build context.
How it connects
Connects Dockerfile instructions, Docker build context, and container images.

Also explained in

Compare how 4 books explain dockerignore →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.