I have a docker image that is about 900MB it has a directory /data
where all the data i want are in and also a /data/.git
directory that i will like to exclude.
I will like to create a data container(using busybox image for example) with only the data under the /data
excluding the /data/.git
directory
How do i do this in the most efficient way?
The /data
excluding the /data/.git
is only about 130MB
So basically i will have data container having roughly 130MB to 200MB compared to the other docker image that is 900MB huge
Thanks
I'd migrate to a named volume, and create it with the following:
The
cp -av /data/* /target
will ignore all of the dot files, so you may need to add others manually if you have more than just the ".git", e.g.cp -av /data/* /data/.app-files /target
If you're willing to first create it with a full copy of /data and then delete the .git folder later, that's even easier:
As long as "data-vol" has not been initialized, it will be created with the full /data contents by Docker. And then the first command you run is to clean the ".git" folder.
Once you have the "data-vol" volume, you can reused it in another other container with: