Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Another 20MB could be removed #146

Closed
030 opened this issue May 2, 2019 · 3 comments
Closed

Another 20MB could be removed #146

030 opened this issue May 2, 2019 · 3 comments

Comments

@030
Copy link

030 commented May 2, 2019

What about running the RUN commands in one layer instead of three, see https://devops.stackexchange.com/a/417/210

https://github.com/tianon/docker-brew-ubuntu-core/blob/5a80061eeed1a4c395066d922bf7f1a0ea79e73c/bionic/Dockerfile

This will save another 20MB according to docker-dive.

[● Layers]─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Cmp   Size  Command
    102 MB  FROM sha256:604cbde1
     745 B  set -xe   && echo '#!/bin/sh' > /usr/sbin/policy-rc.d  && echo 'exit 101' >> /usr/sbin/policy-rc.d  && chmod +x /usr/sbin/p
       0 B  rm -rf /var/lib/apt/lists/*
       7 B  mkdir -p /run/systemd && echo 'docker' > /run/systemd/container
    107 MB  #(nop) COPY dir:b6a97e3dcbfe0203a201aa5e7df785baf454a2e18887f646908dd745d8e236a9 in /opt/jre
    9.1 MB  #(nop) COPY dir:e97b9defdb1d20da0a2b370c5c9a7a1141788b290044b76bd8a9358ac4f31238 in /opt/tomcat

[Layer Details]────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Digest: sha256:604cbde1a4c8fee1b102f8b64d4f41e62d770b5f8a6b06fb809cfd873a2643c3
Command:
#(nop) ADD file:7ce84f13f11609a50ece7823578159412e2299c812746d1d1f1ed5db0728bd37 in /

[Image Details]────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Total Image size: 218 MB
Potential wasted space: 20 MB
Image efficiency score: 90 %

Count   Total Space  Path
    2        6.2 MB  /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_main_binary-amd64_Packages
    2        4.0 MB  /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_main_binary-amd64_Packages
    2        3.2 MB  /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_main_i18n_Translation-en
    2        2.4 MB  /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_main_i18n_Translation-en
    2        2.2 MB  /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_bionic-security_main_binary-amd64_Packages
    2        1.6 MB  /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_bionic-security_main_i18n_Translation-en
    2        242 kB  /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_InRelease
    2         94 kB  /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_restricted_binary-amd64_Packages
    2         89 kB  /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_bionic-security_InRelease
    2         89 kB  /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_InRelease
    2         82 kB  /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_restricted_binary-amd64_Packages
    2         34 kB  /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_bionic-security_restricted_binary-amd64_Packages
    2         17 kB  /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_restricted_i18n_Translation-en
    2         12 kB  /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic-updates_restricted_i18n_Translation-en
    2        6.9 kB  /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_bionic-security_restricted_i18n_Translation-en
    2         234 B  /var/lib/dpkg/diversions
    2           0 B  /var/lib/apt/lists/auxfiles
    2           0 B  /var/lib/apt/lists/lock
    2           0 B  /var/lib/apt/lists/partial
@030
Copy link
Author

030 commented May 2, 2019

I have built two images. The first one with the multiple RUN statements and the second with the concatenated RUN. The outcome seems to be the same. I think that a multistage build will reduce the size of the docker image.

@tianon
Copy link
Owner

tianon commented May 2, 2019

Duplicate of #90

@tianon tianon marked this as a duplicate of #90 May 2, 2019
@030
Copy link
Author

030 commented May 2, 2019

@030 030 closed this as completed May 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants