Skip to content

Latest commit

 

History

History
50 lines (33 loc) · 1.39 KB

README.md

File metadata and controls

50 lines (33 loc) · 1.39 KB

Docker Context

Demonstrate how to work with Docker context.

TODO:

  • Test if modifying the dockerignore causes a cache invalidation in the correct places.

📋 Script to follow

  • Show a docker context issue (large files)
  • Using .dockerignore to prevent bloating the docker context and increasing build times.
  • Use a selective whitelist in the context.

ℹ️ NOTES:

  • If you're building an image and installing node_modules inside the container you should using a .dockerignore file.

Large file and folders

# make a large file
mkfile 200m ./large_file.bin

No Ignore

# rebuild the image (included in context)
docker build --no-cache -f Dockerfile.bash -t scratchtest .

Ignored

# rebuild (it will not copy the 200mb file into the context)
docker build --no-cache -f ./Dockerfile.ignored -t scratchtest .

Selective inclusion (whitelist)

# exclude everything and select some folders
docker build --no-cache -f Dockerfile.whitelist -t whitelisttest ../

Resources

  • How to specify different .dockerignore files for different builds in the same project? here
  • dockerignore file to ignore everything except two folders and their contents is not working here