Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I mount my project as volume, and i want to tell docker to ignore git and phpstorm files when building or any solution to let me commit files to git after.

I tried the .dockerignore file solution but i found git files in the running container :(

this is my dockerignore file code (placed in the root)

.git

any help please ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
284 views
Welcome To Ask or Share your Answers For Others

1 Answer

Docker volumes work at the filesystem level, they are a direct mapping of a directory into your container.

The .dockerignore file is used to affect what the docker client sends to the docker host for your image build (aka the build context).

These are two different phases of docker. The build time creates your image. While the volume at run time affects the container. So you cannot control a host volume mount with the .dockerignore file.

What you can do is add the files to your image. If you also need those files in a volume, you can initialize a named volume with the state of the image, but that only happens when the volume is empty and won't pickup changes made later.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...