goldmann / docker-squash

Docker image squashing tool
MIT License
848 stars 109 forks source link

docker pip #209

Closed splitice closed 2 years ago

splitice commented 2 years ago

not compatible with docker pip package 6.0.0 yet pipfile requests any version.

2022-08-19 01:[15](https://github.com/HalleyAssist/mothership-api/runs/7910122219?check_suite_focus=true#step:6:16):32,594 root         ERROR    module 'docker' has no attribute 'version_info'
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.8/site-packages/docker_squash/image.py", line 357, in _save_image
    if docker.version_info[0] < 3:
AttributeError: module 'docker' has no attribute 'version_info'

Please restrict to <6

SamMorrowDrums commented 2 years ago

@goldmann sorry for the direct ping but I wanted to bring this one to your attention because it is a breaking change. Thanks for everything. I see @enterJazz already submitted a PR - not sure if it needs a way to handle both the new and old method, so might be that it's not quite ready to go, but I wanted to +1 that this issue is going to affect increasing numbers of people.

SamMorrowDrums commented 2 years ago

@enterJazz also worth noting - if you want to build a single layer docker image, you can do this with buildkit. No need for third party squasher.

FROM ubuntu:focal as stage1
# DO ALL THE THINGS

FROM scratch as stage2
COPY --from=stage1 / /
# DO ENV AND ANY REMAINING THINGS
enterJazz commented 2 years ago

@enterJazz also worth noting - if you want to build a single layer docker image, you can do this with buildkit. No need for third party squasher.

FROM ubuntu:focal as stage1
# DO ALL THE THINGS

FROM scratch as stage2
COPY --from=stage1 / /
# DO ENV AND ANY REMAINING THINGS

I use it to obfuscate build history of images; I guess buildkit could also be used in this way, yet it would be also a little hacky and less straight-forward than using the tool. But then again, buildkit probably does not break without warning :)

SamMorrowDrums commented 2 years ago

@enterJazz it's not hacky - it's literally the docker suggestion and the reason they are not supporting --squash everywhere - this covers basically all use-cases.

 docker history f2a8585923940edebfbb82a64f655eebbb99870657f9fef1fc1fca437f1a550b
IMAGE          CREATED              CREATED BY                                      SIZE      COMMENT
f2a858592394   About a minute ago   VOLUME [/var/lib/docker]                        0B        buildkit.dockerfile.v0
<missing>      About a minute ago   CMD ["sudo" "supervisord" "--configuration" …   0B        buildkit.dockerfile.v0
<missing>      About a minute ago   ENTRYPOINT ["/usr/local/share/docker-init.sh…   0B        buildkit.dockerfile.v0
<missing>      About a minute ago   COPY / / # buildkit                             8.27GB    buildkit.dockerfile.v0

It leaves you with a clean history.

The dockerfile in question here has loads of build steps. You only get the one large layer.

enterJazz commented 2 years ago

@SamMorrowDrums I see- I guess it makes more sense to use buildkit in my case than this tool; will try it out, thanks!