Home >Backend Development >Golang >Why Can't My Custom Go Binary Run in an Alpine Docker Image?
Installed Go Binary Not Found in Path on Alpine Linux Docker
This question arises when attempting to run a custom Go binary on an Alpine Docker image, where the binary fails to be found in the path. While Alpine's default Go binary works as expected, custom binaries encounter the "not found" error.
The issue stems from a missing compatibility link in Alpine Linux. The binary relies on a specific dynamic library (e.g., /lib64/ld-linux-x86-64.so.2), but Alpine doesn't have a direct symlink to that library.
To resolve this issue, execute the following command within the Dockerfile:
RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
This command creates the necessary symlink between compatible dynamic libraries, allowing the custom Go binary to find the required dependencies and execute successfully.
The above is the detailed content of Why Can't My Custom Go Binary Run in an Alpine Docker Image?. For more information, please follow other related articles on the PHP Chinese website!