Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
behemphi opened this issue Sep 16, 2015 · 8 comments
Closed

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

behemphi opened this issue Sep 16, 2015 · 8 comments
Labels

Comments

@behemphi
Copy link

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.

@muhmuhten
Copy link
Contributor

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.

@andyshinn
Copy link
Contributor

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?

@behemphi
Copy link
Author

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.

@karthequian
Copy link

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.

@andyshinn
Copy link
Contributor

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

@behemphi
Copy link
Author

behemphi commented Oct 6, 2015

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

@progrium
Copy link
Contributor

progrium commented Oct 6, 2015

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 notifications@github.com
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
#78 (comment)
.

Jeff Lindsay
http://progrium.com

@behemphi
Copy link
Author

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

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

ernoaapa added a commit to ernoaapa/eliot that referenced this issue Dec 31, 2017
Previously eliotd Docker image what we produced were failing to
following error in Linuxkit:
standard_init_linux.go:195: exec user process caused "no such file or directory"

After testing out the binaries in alpine container, got error:
sh: /eliotd: not found

Found similar issue here:
gliderlabs/docker-alpine#78

Fixed by compiling binaries with CGO_ENABLED=0.
Also added container text execution to Circleci to verify
that container works.
ernoaapa added a commit to ernoaapa/eliot that referenced this issue Dec 31, 2017
Previously eliotd Docker image what we produced were failing to
following error in Linuxkit:
standard_init_linux.go:195: exec user process caused "no such file or directory"

After testing out the binaries in alpine container, got error:
sh: /eliotd: not found

Found similar issue here:
gliderlabs/docker-alpine#78

Fixed by compiling binaries with CGO_ENABLED=0.
Also added container text execution to Circleci to verify
that container works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants