Docker rootless image size close to twice as big #6317

Closed
opened 2025-11-02 06:52:23 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @lafriks on GitHub (Nov 15, 2020).

Looks like dockerfile command chown & chmod creates new layer in size of gitea binary that makes image close to twice as big.
see: https://github.com/go-gitea/gitea/blob/master/Dockerfile.rootless#L54
and: https://hub.docker.com/layers/gitea/gitea/latest-rootless/images/sha256-b55c30e134a5ce42aaf3cb94402c3ac98294ffbbb82ea1a70e9c669a586b0441?context=explore

Maybe file could be chown'ed and chmod'ed before building docker image?

Originally created by @lafriks on GitHub (Nov 15, 2020). Looks like dockerfile command `chown & chmod` creates new layer in size of gitea binary that makes image close to twice as big. see: https://github.com/go-gitea/gitea/blob/master/Dockerfile.rootless#L54 and: https://hub.docker.com/layers/gitea/gitea/latest-rootless/images/sha256-b55c30e134a5ce42aaf3cb94402c3ac98294ffbbb82ea1a70e9c669a586b0441?context=explore Maybe file could be chown'ed and chmod'ed before building docker image?
GiteaMirror added the topic/build label 2025-11-02 06:52:23 -06:00
Author
Owner

@lafriks commented on GitHub (Nov 15, 2020):

ping @sapk

@lafriks commented on GitHub (Nov 15, 2020): ping @sapk
Author
Owner

@silverwind commented on GitHub (Nov 15, 2020):

There's a --squash flag on docker build to merge layers but it's been considered experimental for years. Interestingly, it seems not experimental on docker buildx.

Every RUN generally creates a layer so if you want minimum size, either use a single chained RUN or --squash.

@silverwind commented on GitHub (Nov 15, 2020): There's a `--squash` flag on [`docker build`](https://docs.docker.com/engine/reference/commandline/build/) to merge layers but it's been considered experimental for years. Interestingly, it seems not experimental on [`docker buildx`](https://docs.docker.com/engine/reference/commandline/buildx_build/). Every `RUN` generally creates a layer so if you want minimum size, either use a single chained `RUN` or `--squash`.
Author
Owner

@lafriks commented on GitHub (Nov 15, 2020):

yes but that will squash all layers that is not so good as base layers are not reused anymore

@lafriks commented on GitHub (Nov 15, 2020): yes but that will squash all layers that is not so good as base layers are not reused anymore
Author
Owner

@lafriks commented on GitHub (Nov 15, 2020):

btw why *linux-amd64|*linux-arm64 tags are needed when there is already tag that has both archs in it?

@lafriks commented on GitHub (Nov 15, 2020): btw why *linux-amd64|*linux-arm64 tags are needed when there is already tag that has both archs in it?
Author
Owner

@techknowlogick commented on GitHub (Nov 15, 2020):

btw why *linux-amd64|*linux-arm64 tags are needed when there is already tag that has both archs in it?

@lafriks docker manifest needs images to already exist

@techknowlogick commented on GitHub (Nov 15, 2020): > btw why *linux-amd64|*linux-arm64 tags are needed when there is already tag that has both archs in it? @lafriks docker manifest needs images to already exist
Author
Owner

@lafriks commented on GitHub (Nov 15, 2020):

oh, ok

@lafriks commented on GitHub (Nov 15, 2020): oh, ok
Author
Owner

@silverwind commented on GitHub (Nov 16, 2020):

Should probably switch to docker buildx for cross-platform builds at some point.

https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408

@silverwind commented on GitHub (Nov 16, 2020): Should probably switch to `docker buildx` for cross-platform builds at some point. https://medium.com/@artur.klauser/building-multi-architecture-docker-images-with-buildx-27d80f7e2408
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6317