You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference-manual/native-image/guides/build-static-and-mostly-static-executable.md
+7-5
Original file line number
Diff line number
Diff line change
@@ -15,10 +15,10 @@ However, you can create a statically linked or mostly-static linked native execu
15
15
A static native executable is easy to distribute and deploy on a slim or distroless container (a scratch container).
16
16
You can create a static native executable by statically linking it against [musl-libc](https://musl.libc.org/), a lightweight, fast and simple `libc` implementation.
17
17
18
-
**A mostly-static native executable** is a binary that links everything except the standard C library, `glibc`. This is an alternative option to staticly linking everything.
18
+
**A mostly-static native executable** is a binary that links everything (`zlib`, JDK shared libraries) except the standard C library, `libc`. This is an alternative option to staticly linking everything. Also, depending on the user's code, it may link `libstdc+` and `libgcc`.
19
19
This approach is ideal for deployment on a distroless container image.
20
20
21
-
> Note: This currently only works when linked against `glibc`.
21
+
> Note: This currently only works when linked against `libc`.
22
22
23
23
This guide shows how you can take advantage of Native Image linking options including fully dynamic, fully static, and mostly static (except `libc`) to generate an executable ideal for your deployment scenario.
24
24
@@ -100,8 +100,7 @@ This application iterates over your environment variables and prints out the one
100
100
101
101
## Build a Mostly-Static Native Executable
102
102
103
-
With GraalVM Native Image you can build a mostly-static native executable that statically links everything except `libc`.
104
-
Statically linking all your libraries except `glibc` ensures your application has all the libraries it needs to run on any Linux `glibc`-based distribution.
103
+
With GraalVM Native Image you can build a mostly-static native executable that statically links everything except `libc`. Statically linking all your libraries except `libc` ensures your application has all the libraries it needs to run on any Linux `libc`-based distribution.
105
104
106
105
To build a mostly-static native executable, use this command:
107
106
@@ -115,12 +114,15 @@ To build a a mostly-static native executable for the above `EnvMap` demo, run:
This produces a native executable that statically links all involved libraries (including JDK shared libraries) except for`libc`. This includes `zlib`. Also, depending on the user's code, it may link `libstdc+` and `libgcc`.
118
+
One way to check what dynamic libraries your application depends on is to run `ldd` with the native executable, for example, `ldd helloworld`.
119
+
118
120
### Frequently Asked Questions
119
121
120
122
#### What is the recommended base Docker image for deploying a static or mostly-static native executable?
121
123
122
124
A fully static native executable gives you the most flexibility to choose a base container image - it can run on anything including a `FROM scratch` image.
123
-
A mostly-static native executable requires a container image that provides `glibc`, but has no additional requirements.
125
+
A mostly-static native executable requires a container image that provides `libc`, but has no additional requirements.
124
126
In both cases, choosing the base container image generally depends on your native executable's specific requirements.
0 commit comments