docker-volume-backup icon indicating copy to clipboard operation
docker-volume-backup copied to clipboard

Reduce layers / use Docker CLI to reduce img size

Open tekgator opened this issue 4 years ago • 10 comments

Hi Jarno,

I reduzed the image size by more than 50% (411MB vs 857MB) by reducing layers and installing only the Docker CLI.

size

First step was reducing the amount of layers, this reduced the image to around 600MB. Second step was removing the complete docker installation, so the image size shrinks to around 450 MB.

After adding an apt-clean and removing tmp files the image is finally reduced to 411 MB:

image

tekgator avatar Mar 26 '21 13:03 tekgator

I believe the image size can be reduced even more by consolidating the other layers into one layer, but then the code is most likly not so readable anymore and it only saves you a few MB.

tekgator avatar Mar 26 '21 13:03 tekgator

Another possibility would be to remove the Docker CLI completly. You can actually just mount /usr/bin/docker into the container to achive the same result.

This would bring the image size down to 237MB

image

tekgator avatar Mar 26 '21 14:03 tekgator

+1 to PR Correct way to srink image following best practices. But im at mobile and cannot check deb amd64.

About remove docker cli..., should or could container be able to manage remote instances? In that case cli is mandatory

varhub avatar Mar 26 '21 17:03 varhub

@varhub I believe remote access is not required as the backup volumes need to be local as well. At least I cannot think of another possibility right now.

tekgator avatar Mar 27 '21 07:03 tekgator

Hello @tekgator , Im only trying to be wide (even it makes no sense). I dont know if this scenario is viable: Use a second pc as backup host of other machines. It will mount volumes via nfs and support multiple docker instances by mounting/accessing appropriate docker port/socket.

On the other hand, halving again container size is great.

Even if this could be viable, without locallan or vpn or ipv6 will not be feasible. What do you think?

varhub avatar Mar 27 '21 08:03 varhub

@varhub You're correct, but still I see another problem. Even though lets says remote backup (nfs) is a topic the image by itself does not support remote docker control yet. Here we would need the ability to pass IP and port to the container. Most likly remote control is also secured by username/pass or even via SSL certificate. In this case it needs to be passed to the container as well somehow.

Until this is implemented I think it would be save to remove the Docker CLI from the image and just mount it from the host system via /usr/bin/docker. Then there is also no worries about arm / amd64 etc.

tekgator avatar Mar 27 '21 09:03 tekgator

Indeed. Thanks @tekgator for dive me in.

varhub avatar Mar 27 '21 16:03 varhub

Sorry @tekgator.

I forgot about this PR and just create 2 more that overlaps it (#53 , #54).

varhub avatar Feb 13 '22 14:02 varhub

@tekgator the 2 PR's referenced above have been merged.

Is there something here that's not covered there?

jareware avatar Mar 02 '22 09:03 jareware

@jareware: I guess it is fine, even though my PR utilized the package manager instead of the docker install script. Not sure if this is any better. As mentioned I think the Docker CLI could be removed as well as there is no need for it. This would bring down image even further.

From my point of view it can be closed, just don't understand how this overlap happened in the first place.

tekgator avatar Mar 02 '22 12:03 tekgator