skynetservices/skydns

skydns command cannot be found in docker container

IDUnderCover opened this issue · 1 comments

I have successfully built the skydns follow the instruction

go get github.com/skynetservices/skydns
cd $GOPATH/src/github.com/skynetservices/skydns
go build -v

it works well on my host machine, but when i try to run the skydns in docker container, the terminal responds with "docker: Error response from daemon: Container command not found or does not exist..". And im sure the skydns binary file is exist in the root directory.

$ docker run -dP skydns
5a1dd21f1eb752587f3a8866a9243638767934a18c6ffd73d527934184810ddb
docker: Error response from daemon: Container command not found or does not exist..

$ docker run -ti --entrypoint=/bin/sh skydns
/ # ls -al
total 18984
drwxr-xr-x   17 root     root          4096 Apr 17 14:27 .
drwxr-xr-x   17 root     root          4096 Apr 17 14:27 ..
-rwxr-xr-x    1 root     root             0 Apr 17 14:26 .dockerenv
-rwxr-xr-x    1 root     root             0 Apr 17 14:26 .dockerinit
drwxr-xr-x    2 root     root          4096 Apr  1 18:56 bin
drwxr-xr-x    5 root     root           380 Apr 17 14:26 dev
drwxr-xr-x   13 root     root          4096 Apr 17 14:26 etc
drwxr-xr-x    2 root     root          4096 Apr  1 18:56 home
drwxr-xr-x    5 root     root          4096 Apr  1 18:56 lib
lrwxrwxrwx    1 root     root            12 Apr  1 18:56 linuxrc -> /bin/busybox
drwxr-xr-x    5 root     root          4096 Apr  1 18:56 media
drwxr-xr-x    2 root     root          4096 Apr  1 18:56 mnt
dr-xr-xr-x  231 root     root             0 Apr 17 14:26 proc
drwx------    2 root     root          4096 Apr 17 14:26 root
drwxr-xr-x    2 root     root          4096 Apr  1 18:56 run
drwxr-xr-x    2 root     root          4096 Apr  1 18:56 sbin
-rwxr-xr-x    1 root     root      19380864 Apr 17 00:36 skydns
dr-xr-xr-x   13 root     root             0 Apr 17 14:12 sys
drwxrwxrwt    2 root     root          4096 Apr  1 18:56 tmp
drwxr-xr-x    7 root     root          4096 Apr  1 18:56 usr
drwxr-xr-x   10 root     root          4096 Apr  1 18:56 var
/ # ./skydns 
/bin/sh: ./skydns: not found

the Dockerfile is

FROM alpine:latest                                                                                                                                    
MAINTAINER Miek Gieben <miek@miek.nl> (@miekg)
RUN apk --update add bind-tools && rm -rf /var/cache/apk/*
ADD skydns skydns
EXPOSE 53 53/udp
ENTRYPOINT ["/skydns"]

finally, I copy the skydns binary file into ubuntu:14.04 container, and it works well.

$ docker run -ti ubuntu:14.04 /bin/bash
$ docker cp skydns 49b3d:/

root@49b3d865abb2:/# ./skydns 
2016/04/17 15:08:04 skydns: falling back to default configuration, could not read from etcd: client: etcd cluster is unavailable or misconfigured
2016/04/17 15:08:04 skydns: metrics enabled on :/metrics
2016/04/17 15:08:04 skydns: ready for queries on skydns.local. for tcp://127.0.0.1:53 [rcache 0]
2016/04/17 15:08:04 skydns: ready for queries on skydns.local. for udp://127.0.0.1:53 [rcache 0]

Why the command skydns cannot be found in alpine based container?

my docker version is

 Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Sat Mar 12 19:18:57 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Sat Mar 12 19:18:57 2016
 OS/Arch:      linux/amd64

uname -a 
Linux arch-docker 4.5.0-1-ARCH #1 SMP PREEMPT Tue Mar 15 09:41:03 CET 2016 x86_64 GNU/Linux

Hello there,

Concerning your first point, as the go build command has no interaction with Docker, did you followed these steps (as describe in the README) beforehand ?

$ cd $GOPATH/src/github.com/skynetservices/skydns
$ GOOS=linux go build -a -tags netgo -installsuffix netgo
$ docker build -t skydns .

$ docker images | grep skydns                            
skydns              latest              9fff2b6a3de0        6 seconds ago       27.49 MB

And the image is actually working as it should :

$ docker run -ti skydns
2016/04/29 08:12:21 skydns: falling back to default configuration, could not read from etcd: client: etcd cluster is unavailable or misconfigured
2016/04/29 08:12:21 skydns: metrics enabled on :/metrics
2016/04/29 08:12:21 skydns: ready for queries on skydns.local. for tcp://127.0.0.1:53 [rcache 0]
2016/04/29 08:12:21 skydns: ready for queries on skydns.local. for udp://127.0.0.1:53 [rcache 0]

$ docker version
Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Sat Mar 12 19:18:57 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Sat Mar 12 19:18:57 2016
 OS/Arch:      linux/amd64
$ uname -a
Linux thinkpad 4.5.1-1-ARCH #1 SMP PREEMPT Thu Apr 14 19:19:32 CEST 2016 x86_64 GNU/Linux