grammarly/rocker

rsync issue

Closed this issue · 1 comments

With the following Rockerfile,

FROM golang:1.7.4
RUN mkdir -p $GOPATH/src/github.com/digitalocean/bind_exporter && \
    cd $GOPATH/src/github.com/digitalocean/bind_exporter && \
    git clone https://github.com/digitalocean/bind_exporter.git . && \
    go get && \
    go build -v && \
    ls -l /go/bin
EXPORT /go/bin/ /app

#####################################################################
FROM busybox
IMPORT /app
CMD ["/app/bind_exporter"]
TAG bind_exporter:{{ .Version }}

Build looks reasonable:

$ rocker build -var Version=v1
INFO[0000] MAINTAINER Andrew Hammond ahammond@anchorfree.net
INFO[0000] Cleaning up
INFO[0000] ====================================
INFO[0000] FROM golang:1.7.4
INFO[0000] | Image sha256:9752d                          size=673.9 MB
INFO[0000] RUN mkdir -p $GOPATH/src/github.com/digitalocean/bind_exporter &&     cd $GOPATH/src/github.com/digitalocean/bind_exporter &&     git clone https://github.com/digitalocean/bind_exporter.git . &&     go get &&     go build -v &&     ls -l /go/bin
INFO[0000] | Not cached
INFO[0000] | Created container a4d5c006e90a (image sha256:9752d)
Cloning into '.'...
github.com/digitalocean/bind_exporter
total 9764
-rwxr-xr-x 1 root root 9995000 Dec  3 05:37 bind_exporter
INFO[0065] Commit changes
INFO[0065] | Result image is sha256:0f4d1                size=705.1 MB (+31.23 MB)
INFO[0065] | Removing container a4d5c006e90a
INFO[0065] EXPORT /go/bin /app
INFO[0065] | Create container: rocker_exports_b5537785db59378300ba1823 for exports
INFO[0066] | Using exports container rocker_exports_b5537785db59378300ba1823
INFO[0066] | Created container c2e497e12a01 (image sha256:0f4d1)
INFO[0066] | Running in c2e497e12a01: /opt/rsync/bin/rsync -a --delete-during /go/bin /.rocker_exports/app
INFO[0067] | Removing container c2e497e12a01
INFO[0067] Commit changes
INFO[0067] | Created container 07817fa24b67 (image sha256:0f4d1)
INFO[0067] | Result image is sha256:7d80e                size=705.1 MB (+0 B)
INFO[0067] | Removing container 07817fa24b67
INFO[0067] Cleaning up
INFO[0067] ====================================
INFO[0067] FROM busybox
INFO[0067] | Image sha256:e02e8                          size=1.093 MB
INFO[0067] IMPORT /app
INFO[0067] | Using exports container rocker_exports_b5537785db59378300ba1823
INFO[0067] | Import from rocker_exports_b5537785db59378300ba1823 (03952b224e19)
INFO[0067] | Not cached
INFO[0067] | Created container 5bd6d166efb8 (image sha256:e02e8)
INFO[0067] | Running in 5bd6d166efb8: /opt/rsync/bin/rsync -a /.rocker_exports/app /
INFO[0068] Commit changes
INFO[0069] | Result image is sha256:12f32                size=11.09 MB (+9.995 MB)
INFO[0069] | Removing container 5bd6d166efb8
INFO[0069] CMD ["/app/bind_exporter"]
INFO[0069] Commit changes
INFO[0069] | Created container 998209627e78 (image sha256:12f32)
INFO[0069] | Result image is sha256:bc79d                size=11.09 MB (+0 B)
INFO[0069] | Removing container 998209627e78
INFO[0069] TAG bind_exporter:v1
INFO[0069] | Tag sha256:bc79d -> bind_exporter:v1
INFO[0069] Cleaning up
INFO[0069] Successfully built sha256:bc79d | final size 11.09 MB (+9.995 MB from the base image)

But when I run, I get the following error:

$ docker run bind_exporter:v1
panic: standard_init_linux.go:175: exec user process caused "no such file or directory" [recovered]
	panic: standard_init_linux.go:175: exec user process caused "no such file or directory"

goroutine 1 [running, locked to thread]:
panic(0x88f8a0, 0xc8201304d0)
	/usr/local/go/src/runtime/panic.go:481 +0x3e6
github.com/urfave/cli.HandleAction.func1(0xc8200fb2e8)
	/tmp/tmp.n151sEscRu/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:478 +0x38e
panic(0x88f8a0, 0xc8201304d0)
	/usr/local/go/src/runtime/panic.go:443 +0x4e9
github.com/opencontainers/runc/libcontainer.(*LinuxFactory).StartInitialization.func1(0xc8200fabf8, 0xc82001e0c8, 0xc8200fad08)
	/tmp/tmp.n151sEscRu/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/factory_linux.go:259 +0x136
github.com/opencontainers/runc/libcontainer.(*LinuxFactory).StartInitialization(0xc82005d630, 0x7fbd897c4728, 0xc8201304d0)
	/tmp/tmp.n151sEscRu/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/opencontainers/runc/libcontainer/factory_linux.go:277 +0x5b1
main.glob.func8(0xc82007aa00, 0x0, 0x0)
	/tmp/tmp.n151sEscRu/src/github.com/opencontainers/runc/main_unix.go:26 +0x68
reflect.Value.call(0x7f45a0, 0x9a4d88, 0x13, 0x8ebac8, 0x4, 0xc8200fb268, 0x1, 0x1, 0x0, 0x0, ...)
	/usr/local/go/src/reflect/value.go:435 +0x120d
reflect.Value.Call(0x7f45a0, 0x9a4d88, 0x13, 0xc8200fb268, 0x1, 0x1, 0x0, 0x0, 0x0)
	/usr/local/go/src/reflect/value.go:303 +0xb1
github.com/urfave/cli.HandleAction(0x7f45a0, 0x9a4d88, 0xc82007aa00, 0x0, 0x0)
	/tmp/tmp.n151sEscRu/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:487 +0x2ee
github.com/urfave/cli.Command.Run(0x8ee970, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x984240, 0x51, 0x0, ...)
	/tmp/tmp.n151sEscRu/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/command.go:191 +0xfec
github.com/urfave/cli.(*App).Run(0xc820001b00, 0xc82000a100, 0x2, 0x2, 0x0, 0x0)
	/tmp/tmp.n151sEscRu/src/github.com/opencontainers/runc/Godeps/_workspace/src/github.com/urfave/cli/app.go:240 +0xaa4
main.main()
	/tmp/tmp.n151sEscRu/src/github.com/opencontainers/runc/main.go:137 +0xe24

It seems that there's an issue exporting the go binary (bind_exporter) from the build image to the distribution image. I think I'm using IMPORT/EXPORT correctly, but I'm fairly new to Rockerfile, so it could totally be that, too. Help?

Nope. Problem was that go wasn't linking statically. Sigh.