There is a shorter and easier method to write your .dockerignore :

vendor/bundle/**/*
vendor/bundle
Answer from sebthemonster on Stack Overflow
🌐
Docker
docs.docker.com › manuals › docker build › build context
Build context | Docker Docs
When you run a build command, the build client looks for a file named .dockerignore in the root directory of the context.
🌐
GeeksforGeeks
geeksforgeeks.org › devops › how-to-use-a-dockerignore-file
How to Use a .dockerignore File? - GeeksforGeeks
April 8, 2024 - Now, similar to a .gitignore file that is commonly used when you build Git repositories, a .dockerignore file is used to ignore files and folders when you try to build a Docker Image.
🌐
Medium
medium.com › @bounouh.fedi › mastering-the-dockerignore-file-boosting-docker-build-efficiency-398719f4a0e1
Mastering the .dockerignore File: Boosting Docker Build Efficiency | by Fedi Bounouh | Medium
November 9, 2024 - As you scale up your Docker projects, managing the build context efficiently becomes increasingly important. So next time you write a Dockerfile, make sure to add a .dockerignore file to the mix — it’s a small trick that can make a big difference!
🌐
CloudBees
cloudbees.com › blog › leveraging-the-dockerignore-file-to-create-smaller-images
Leveraging the dockerignore File to Create Smaller Images
The .dockerignore file is a special file that can be placed within the build context directory. The build context directory is the directory that we specify at the end of a docker build command.
🌐
Codefresh
codefresh.io › home › blog › do not ignore .dockerignore (it’s expensive and potentially dangerous)
Do not ignore .dockerignore (it's expensive and potentially dangerous) | Codefresh
March 13, 2025 - The .dockerignore file is the tool, that can help you to define the Docker build context you really need. Using this file, you can specify ignore rules and exceptions from these rules for files and folder, that won’t be included in the build context and thus won’t be packed into an archive and uploaded to the Docker server.
🌐
Markbirbeck
markbirbeck.com › 2018 › 12 › 07 › getting-control-of-your-dockerignore-files
Getting Control Of Your .dockerignore Files | Mark Birbeck’s Blog
December 7, 2018 - # In .dockerignore # Exclude everything: # * # Now un-exclude package.json and the app folder: # !app !LICENSE !package.json
Find elsewhere
🌐
LinkedIn
linkedin.com › pulse › securing-docker-builds-comprehensive-guide-usage-best-ilyas-ou-sbaa
Securing Docker Builds: A Comprehensive Guide to .dockerignore Usage and Best Practices
July 17, 2023 - Introduction .dockerignore is a text file used by Docker to exclude files and directories from the context that is sent to the Docker daemon during the build process.
🌐
W3Schools
w3schools.io › docker-dockerignore
Learn dockerignore file for ignore files and folders in the docker build for developers - w3schools
It creates a .dockerignore in the current directory. Add each line to this file with the list of files or folders to ignore
🌐
CyberPanel
cyberpanel.net › blog › dockerignore-file
Mastering the .dockerignore file for Optimized Docker builds
July 17, 2025 - The dockerfile ignore refers to controlling what files from your project should be considered when the Dockerfile is processed. This is achieved by using both .dockerignore and COPY/ADD commands effectively in your Dockerfile.
🌐
Nelson
nelson.cloud › posts › ignore files across all subdirectories in .dockerignore
Ignore Files Across All Subdirectories in .dockerignore | Nelson Figueroa
December 9, 2025 - To ignore a file across all subdirectories, prefix the filename with **. For example, to ignore the file file.txt in all subdirectories, add the following to .dockerignore:
🌐
GitHub
github.com › GoogleContainerTools › kaniko › issues › 1486
Dockerignore folders beginning with dot not ignored · Issue #1486 · GoogleContainerTools/kaniko
November 9, 2020 - Actual behavior If the .dockerignore specifies a folder starting with a dot like **/.git and .git is a directory, the folder is printed to be ignored by kaniko, but effectively is instead included in the built image.. It needs **/.git/**...
Author   Patrick-Remy
🌐
Cratecode
cratecode.com › info › docker ignore usage
Docker Ignore Usage | Cratecode
May 13, 2023 - By listing files and directories in your .dockerignore file, you can prevent unnecessary files from being sent to the Docker daemon during the build process, thus optimizing the build time and reducing the image size.
🌐
Medium
medium.com › @LihauTan › took-me-hours-to-realise-why-docker-build-ignores-my-dockerignore-and-this-is-what-ive-learned-2f87c770ea9c
Took me hours to realise why docker build ignores my .dockerignore, and this is what I’ve learned | by Tan Li Hau | Medium
November 26, 2017 - Docker CLI will only look for ... of multiple packages, make sure .dockerignore file is on the root directory of your context, it will ignore it if it is somewhere in the subfolder....
🌐
TechRepublic
techrepublic.com › home › what are .dockerignore files, and why you should use them?
What are .dockerignore files, and why you should use them? - TechRepublic
November 7, 2022 - An added benefit of the .dockerignore file is that it can help shrink the attack plane of your images. You want as little extraneous “stuff” inside your images as possible (especially password files), and sometimes you might launch a build forgetting that you’ve left a few bits and pieces in the build folder...
🌐
OneUptime
oneuptime.com › home › blog › how to use docker ignore files
How to Use Docker Ignore Files
January 25, 2026 - The .dockerignore file tells Docker which files and directories to exclude when building images.
🌐
Ubuntu
manpages.ubuntu.com › manpages › noble › man5 › dockerignore.5.html
Ubuntu Manpage: .containerignore(.dockerignore) - files to ignore buildah or podman build context directory
Before container engines build an image, they look for a file named .containerignore or .dockerignore in the root context directory. If one of these file exists, the CLI modifies the context to exclude files and directories that match patterns specified in the file.
🌐
Docker Community
forums.docker.com › docker desktop
.DockerIgnore WSL2 --Not Ignoring - Docker Desktop - Docker Community Forums
December 13, 2022 - Hello. My .dockerignore file does not seem to ‘ignore’ directories. In the build logs, the .dockerignore file is being loaded. => [internal] load .dockerignore That said, the only .dockerignore command that works is to ignore everything with ‘*’ In my .dockerignore in the project root, ...