docker-squash icon indicating copy to clipboard operation
docker-squash copied to clipboard

Support image tar, without accessing Docker daemon

Open vulyon opened this issue 6 months ago • 6 comments

Enable Docker Daemon-Free Image Squashing

This PR directly addresses and resolves Issue #24: "Make it possible to run squashing without accessing Docker daemon" by introducing the ability for docker-squash to directly process Docker images from tar files. This eliminates the need for a running Docker daemon, significantly enhancing flexibility for image optimization in CI/CD pipelines, air-gapped environments, and systems without Docker installed.

Key Benefits

  • No Docker Daemon Required: Squash images anywhere you can save them as a tar file.
  • Ideal for Restricted Environments: Works seamlessly in CI/CD, air-gapped setups, or when Docker isn't running.
  • OCI Format Support: The tool automatically detects and processes images from OCI-formatted input tar files. Please note: Currently, testing has been focused solely on OCI format images.
  • Preserves Layer History: Ensures compatibility and traceability for your squashed images.

How to Use

  1. Export the Image:

    $ docker save -o source.tar jboss/wildfly:latest
    
  2. Squash from Tar:

    $ python -m docker_squash.cli --input-tar source.tar --tag jboss/wildfly:squashed -f 8 --output-path squashed.tar --load-image false
    
    • Use --input-tar for your source image file.
    • --tag is recommended for the new image name.
    • --output-path specifies where to save the squashed tar file.
    • --load-image false prevents the tool from attempting to load the image directly into a Docker daemon.
  3. Load into Docker (Optional):

    $ docker load -i squashed.tar
    

This enhancement significantly broadens docker-squash's utility, making image size optimization more accessible across diverse development and deployment scenarios.

vulyon avatar Jul 04 '25 07:07 vulyon

hello,sir @goldmann @rnc it appears there's an issue with the runner environment. It looks like the CI/CD checks are failing due to the Ubuntu 20.xx runner deprecation (as per the error message). This doesn't seem to be related to my code changes.

vulyon avatar Jul 04 '25 08:07 vulyon

@lyon-v I've fixed the runners and rebased. However I think you need to run ./support/run_formatter.py to fixup the formatting as well.

rnc avatar Jul 04 '25 14:07 rnc

@rnc Hi there! Apologies for the delayed response. I've fixed the code formatting and it has passed the checks now.

vulyon avatar Jul 06 '25 09:07 vulyon

Sir @rnc @goldmann .Do I need to squash these two commits into a single one?

vulyon avatar Jul 07 '25 02:07 vulyon

@lyon-v Did you wish to discuss any of the comments?

rnc avatar Aug 05 '25 08:08 rnc

sir, my apologies for the slow response. I've been swamped with work lately, but I'll reply to or fix these issues shortly.

vulyon avatar Aug 20 '25 02:08 vulyon