There is a shorter and easier method to write your .dockerignore :
vendor/bundle/**/*
vendor/bundle
Answer from sebthemonster on Stack Overflowdocker - How can I exclude a sub-directory with a .dockerignore file - Stack Overflow
Docker ignore file used in sub directories
That depends on what your docker build command looks like. If you perform a docker build -f app/Dockerfile . from the parent directory where the .dockerignore file is then it would include the .dockerignore but if you are in either app or server and run docker build ., it wouldn't be included as .dockerignore isn't in the build context.
docker - Ignore directories with .dockerignore or volume? - Stack Overflow
docker - Dockerignore: Ignore everything except a file and the Dockerfile - Stack Overflow
Videos
There is a shorter and easier method to write your .dockerignore :
vendor/bundle/**/*
vendor/bundle
With the help of PHPStorm - Click right on project -> then you have an option ".i*" -> then select .dockerignore. It will ask you what type of project you have. I search for symfony PHP in my case. Then it will automatically create a template with all the files that need to be excluded.
After this project seemed to be working more efficiently :)!
Hey,
I have a structure like so.
- Docker.compose.yml
- .dockerignore
- app
- Dockerfile
- server
- Dockerfile
- configDoes my dockerignore file get used in the app and server folders when their respective dockerfiles are run?
If you need to ignore everything except some directories or files and also ignore some unnecessary files inside those allowed directories you can use the following .dockerignore file:
# Ignore everything
*
# Allow files and directories
!/file.txt
!/src
# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
**/*~
**/*.log
**/.DS_Store
**/Thumbs.db
From the dockerfile reference:
Beyond Go’s filepath.Match rules, Docker also supports a special wildcard string ** that matches any number of directories (including zero). For example, **/*.go will exclude all files that end with .go that are found in all directories, including the root of the build context.
So a line containing simply ** will ignore everything in the same directory as the Dockerfile.
As expected the exclamation can then be used to reference any files you do wish to send to the docker daemon.