Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to minimize docker mirroring

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you how to minimize the docker image, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

How to make the mirror as small as possible

I think of from scratch very much, but there is no basic image.

FROM scratchCOPY p / ENTRYPOINT ["/ p"]

There are several points to pay attention to:

ENTRYPOINT or CMD must use [] this mode. If direct / p starts with sh, scratch fails without shell.

Binary programs must be compiled statically, that is, dynamic libraries that cannot rely on libc or something

Dynamically compiled bin programs:

[root@dev-86-205ci-sftp] # ldd p linux-vdso.so.1 = > (0x00007ffd6ef7b000) libpthread.so.0 = > / lib64/libpthread.so.0 (0x00007fa28f94e000) libc.so.6 = > / lib64/libc.so.6 (0x00007fa28f58d000) / lib64/ld-linux-x86-64.so.2 (0x00007fa28fb72000)

The bin program that comes out in this case may have a problem:

Standard_init_linux.go:175: exec user process caused "no such file or directory"

Statically compiled bin programs, which we need for scratch:

[root@dev-86-205ci-sftp] # ldd p is not a dynamic executable file

Static compilation commands in golang:

Go build-- ldflags'--linkmode external-extldflags "- static"

If you don't compile statically, you may have to copy a bunch of dynamic libraries into the image, as many lowB do.

The above is all the contents of the article "how to minimize docker mirroring". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report