Let's focus on a scenario where both Docker and Git are used in a project. In this case it's convenient to maintain both .gitignore and .dockerignore files.
I'm trying to understand the relation between the two files. My beginner's suspicion is that .dockerignore should be a superset of .gitignore and always contain at least the same items.
My reasoning is that if the .dockerignore doesn't list some file that is .gitignored, then our build context on the developer's machine will include this file whereas a build context in the Continuous Integration environment won't (as it only works on files present in the git repository). This can easily lead to a situation where a docker image built locally works, but an image build from the same code on the build server is broken, because it works with a different input data.
Is this true that .dockerignore should typically be a superset of .gitignore? If so, do you actually use some tooling to enforce this relation?
package-lock.jsonin GIT but you may want it in Docker.