Nomad v0.4.1
Alpine Linux 3.3(Docker container)
When I run Nomad on Alpine Linux, I found binary of Nomad v0.4.1 may require glibc for its dynamic link.
I want to know whether this fact is intended.
FYI: There was a similar issue on Terraform.
1.Run container(Alpine 3.3).
$ docker run -it -d --name container alpine:3.3 /bin/sh
2.Exec shell on container.
$ docker exec -it container /bin/sh
3.Update apk repository and install openssl for https.
(container)# apk update && apk add openssl
4.Fetch Nomad archive and extract it.
(container)# wget https://releases.hashicorp.com/nomad/0.4.1/nomad_0.4.1_linux_amd64.zip
(container)# unzip nomad_0.4.1_linux_amd64.zip
5.Try to run Nomad, but can't.
(container)# chmod a+x nomad
(container)# ./nomad version
/bin/sh: ./nomad: not found
6.Check whether Nomad binary is dynamically linked.
(container)# apk add file
(container)# file nomad
nomad: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.24, BuildID[sha1]=7f03d53232d68b13363a878a957e12b46ab356b4, not stripped
(container)# ldd nomad
/lib64/ld-linux-x86-64.so.2 (0x560f4ad1e000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x560f4ad1e000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x560f4ad1e000)
I had similar issues a few days ago using non-Nomad go built binaries (Go 1.7.1) built under a glibc-based Linux, and running on Alpine Linux.
My solution was to use the golang:1.7.1-alpine Docker container to build my project, and publish Alpine specific binaries as part of my release.
Example:
/ # file ecs-discoverer-0.3.3-linux_amd64
ecs-discoverer-0.3.3-linux_amd64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, not stripped
/ # file ecs-discoverer-0.3.3-linux_musl_amd64
ecs-discoverer-0.3.3-linux_musl_amd64: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, not stripped
Possibly related to some dependency requiring cgo...? http://blog.hashbangbash.com/2014/04/linking-golang-statically/
@FGtatsuro this is in fact intended, cgo is used for username and process lookup. see #1624 for a previous answer.
@iverberk
Thank you for your quick replay! So, I'll use Nomad on environments with glibc.
would it not be possible to provide a statically linked version of nomad?
@ForsakenHarmony While it's possible to build a statically linked version of Nomad, the Nomad team currently only officially supports the CGO-enabled version to ease testing.
If you have Go installed you can build a static version by running:
go get github.com/hashicorp/nomad
cd $GOPATH/src/github.com/hashicorp/nomad
CGO_ENABLED=0 go build -o nomad-nocgo
./nomad-nocgo agent -dev # run Nomad!
This binary will lack the ui and lxc.
Most helpful comment
I had similar issues a few days ago using non-Nomad go built binaries (Go 1.7.1) built under a glibc-based Linux, and running on Alpine Linux.
My solution was to use the golang:1.7.1-alpine Docker container to build my project, and publish Alpine specific binaries as part of my release.
Example:
Possibly related to some dependency requiring
cgo...? http://blog.hashbangbash.com/2014/04/linking-golang-statically/