Demonstrate how to work with Docker context.
TODO:
- Test if modifying the dockerignore causes a cache invalidation in the correct places.
- 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.
# make a large file
mkfile 200m ./large_file.bin
# rebuild the image (included in context)
docker build --no-cache -f Dockerfile.bash -t scratchtest .
# rebuild (it will not copy the 200mb file into the context)
docker build --no-cache -f ./Dockerfile.ignored -t scratchtest .
# exclude everything and select some folders
docker build --no-cache -f Dockerfile.whitelist -t whitelisttest ../