You may have noticed that if you put a Dockerfile in your home, and launch a docker build you will see a message uploading context, this means docker creates a .tar with all the files in your home and in all the subdirectories, and uploads this tar to the docker daemon.
If you have some huge files, this may take a long time.
So to avoid this you may
1) create a specific directory, where you put your Dockerfile, and all what is needed for your build
2) tell docker to ignore some files during the build
So you may put in the .dockerignore all the files not needed for your build
Answer from user2915097 on Stack OverflowVideos
What should I include in a .dockerignore?
Node_modules/, vendor/
Log files, *.log
Build artifacts, dist/, target/
Sensitive files, .env This will make your Docker image smaller and more secure.
If my .dockerignore file is not working?
Does the dockerignore file contain case sensitivity?
You may have noticed that if you put a Dockerfile in your home, and launch a docker build you will see a message uploading context, this means docker creates a .tar with all the files in your home and in all the subdirectories, and uploads this tar to the docker daemon.
If you have some huge files, this may take a long time.
So to avoid this you may
1) create a specific directory, where you put your Dockerfile, and all what is needed for your build
2) tell docker to ignore some files during the build
So you may put in the .dockerignore all the files not needed for your build
This what I typically put in .dockerignore for dockerized Django apps
**/*.pyc
**/*.pyo
**/*.mo
.gitignore
.git/
**/__pycache__/
Dockerfile
db.sqlite3
**/*.md