docker-alpine icon indicating copy to clipboard operation
docker-alpine copied to clipboard

Confd binary will not run in Alpine, but will run in Ubuntu

Open behemphi opened this issue 11 years ago • 8 comments

We have a dev build of confd running (Sorry I cannot upload it).

In gliderlabs/alpine trying to execute it gives only the message "not found" as if the file does not exist. One can clearly see the file exists and is executable however.

The exact error looks like this, though I was calling it "foo" at the time:

sh: ./foo: not found

Put the same binary on the host. confd responds as expected.

Bind mount that binary into a the alpine container, and get the same "not found" error.

Bind mount that binary into a ubuntu container, and get the expected result (confd tries to start and yelps about missing config).

So finally ran ldd. I suspect one of these .so is missing:

# ldd foo
    linux-vdso.so.1 =>  (0x00007fff489fe000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbb4ccc3000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbb4c8fe000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fbb4cee6000)

Would be happy to send you the binary if you like.

behemphi avatar Sep 16 '15 22:09 behemphi

it's linked against glibc. musl is not (well, not currently) binary-compatible. you'll want either one built for musl or a statically-linked binary.

muhmuhten avatar Sep 16 '15 22:09 muhmuhten

If VDSO is the only external link, it might be possible to static compile the binary. Check out the static cgo section of http://blog.hashbangbash.com/2014/04/linking-golang-statically/.

Can you give some info on how confd was compiled?

andyshinn avatar Sep 16 '15 23:09 andyshinn

Sorry for the false alarm @andyshinn and thanks @muhmuhten I missed the libc in the output, so its is not statically compiled (my assumption)

I am tagging @karthequian to answer the question on how it was compiled in case there is a nugget here.

behemphi avatar Sep 17 '15 14:09 behemphi

Hey guys. To compile the binary, I just used the recommended way to build the confd binary from the project (https://github.com/kelseyhightower/confd) on an ubuntu vm. Confd uses the gb build tool. I can try the static build and see if we have the same result.

karthequian avatar Sep 17 '15 16:09 karthequian

Hmm, something must be different in the build process. The 0.10 confd release is a static binary and the ldd output from @behemphi suggests yours is not:

$ dria                                                                                                                               ~/Projects/gliderlabs/docker-alpine
/ # apk-install ca-certificates wget
fetch http://alpine.gliderlabs.com/alpine/v3.2/main/x86_64/APKINDEX.tar.gz
(1/9) Installing run-parts (4.4-r0)
(2/9) Installing openssl (1.0.2d-r0)
(3/9) Installing lua5.2-libs (5.2.4-r0)
(4/9) Installing lua5.2 (5.2.4-r0)
(5/9) Installing ncurses-terminfo-base (5.9-r3)
(6/9) Installing ncurses-widec-libs (5.9-r3)
(7/9) Installing lua5.2-posix (33.3.1-r2)
(8/9) Installing ca-certificates (20141019-r2)
(9/9) Installing wget (1.16.3-r0)
Executing busybox-1.23.2-r0.trigger
Executing ca-certificates-20141019-r2.trigger
OK: 8 MiB in 24 packages
/ # wget -q https://github.com/kelseyhightower/confd/releases/download/v0.10.0/confd-0.10.0-linux-amd64
/ # ldd confd-0.10.0-linux-amd64
ldd: confd-0.10.0-linux-amd64: Not a valid dynamic program

andyshinn avatar Sep 17 '15 16:09 andyshinn

If someone runs across this, here is what I had to do in the end:

  • Upgrade to golang 1.5.1 (gb did not support cross compiling from Darwin on 1.4.x it would seem)
  • Remove my packages directory (because many were of the 1.4 flavor)
  • Install gb sudo GOPATH=/Users/boyd/go go get github.com/constabulary/gb/...
  • Cross compile and ensure no use of cgo: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 gb build all

The binary landed in bin/confd-linux-amd64

behemphi avatar Oct 06 '15 00:10 behemphi

Also if you dig around there is a glibc package for Alpine that Andy put together.

On Mon, Oct 5, 2015 at 7:30 PM, Boyd Hemphill [email protected] wrote:

If someone runs across this, here is what I had to do in the end:

  • Upgrade to golang 1.5.1 (gb did not support cross compiling from Darwin on 1.4.x it would seem)
  • Remove my packages directory (because many were of the 1.4 flavor)
  • Install gb sudo GOPATH=/Users/boyd/go go get github.com/constabulary/gb/...
  • Cross compile and ensure no use of cgo: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 gb build all

The binary landed in bin/confd-linux-amd64

— Reply to this email directly or view it on GitHub https://github.com/gliderlabs/docker-alpine/issues/78#issuecomment-145706573 .

Jeff Lindsay http://progrium.com

progrium avatar Oct 06 '15 01:10 progrium

Here is an example of what @progrium is talking about. Thanks guys!

https://github.com/stackhub/service-prometheus/blob/master/Dockerfile

behemphi avatar Oct 18 '15 21:10 behemphi