gcs-helper icon indicating copy to clipboard operation
gcs-helper copied to clipboard

Issues building docker image

Open jdavey opened this issue 4 years ago • 2 comments

I'm trying to build the docker image and am having problems running it:

go build -o gcs-helper
docker build -t gcs-helper:latest .
docker run -t gcs-helper:latest
standard_init_linux.go:207: exec user process caused "exec format error"

I'm running on macOS, go version go1.14.2 darwin/amd64, docker 18.09.1

jdavey avatar Apr 10 '20 19:04 jdavey

@jdavey That error seems to be due to system arch differences from compiling the executable on MacOS but trying to run in Linux env.

Interestingly, if I try building the executable on Debian, and try to run the Dockerfile I get a different error.

$ docker run --rm -it gcs-helper:local
standard_init_linux.go:211: exec user process caused "no such file or directory"

I see the gcs-helper executable in the /usr/bin directory, but it does not run.

/ # gcs-helper
/bin/sh: gcs-helper: not found
/ # ls -lah /usr/bin/ | grep gcs
-rwxr-xr-x    1 root     root       15.5M Apr 10 20:00 gcs-helper
/ # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

But, if I run the same executable inside the golang:1.14.2-stretch image, it works.

It seems like the base alpine image is missing some shared object file dependencies.

golang:1.14.2-stretch

root@3a1137bfd01f:/usr/src/app# ldd gcs-helper
        linux-vdso.so.1 (0x00007ffe539f9000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb8dd4f2000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb8dd153000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fb8dd70f000)

alpine:3.11.3

/usr/bin # ldd ./gcs-helper
        /lib64/ld-linux-x86-64.so.2 (0x7f80df921000)
        libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f80df921000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f80df921000)

Clee681 avatar Apr 10 '20 20:04 Clee681

Update: I was able to fix the alpine image by symlinking the musl library to the location that the linker wants.

mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2

musl bundles shared libraries in a single file including libpthread, so creating the symlink for /lib/libc.musl-x86_64.so.1 is all that was needed.

Clee681 avatar Apr 10 '20 21:04 Clee681