Static Go Binaries w/ Docker – Entrypoint Not Found

I used Static Go Binaries with Docker on OSX by Nicola Paolucci to try to use static Go binary w/ Docker. I believe I followed every step correctly, but when I run the final image, I get the following error response from Docker.

NOTE The name of my service and executable are netverify

  • permission issue with docker under windows
  • Send a wake on lan packet from a docker container
  • Required ports for JMS using HornetQ (JBoss) to expose on docker container
  • Docker official image Tomcat can not resolve host in /etc/hosts
  • Multiple Python Scripts in Docker
  • Can't start or list docker Machines created on another partition
  • docker: Error response from daemon: Container command '/netverify' not found or does not exist..

    My Dockerfile.static looks like the following…

    #Create a minimal container to run a Golang static binary
    FROM tianon/true
    ADD netverify /
    EXPOSE 8282
    CMD ["/netverify"]

    My looks like the following…

    FROM golang
    ADD Makefile /
    RUN make setup
    ADD . /go/src/
    RUN make buildgo
    CMD ["/bin/bash"]

    My Makefile is the following…

    GOCMD = go
    GOBUILD = $(GOCMD) build
    GOGET = $(GOCMD) get -v
    GOCLEAN = $(GOCMD) clean
    GOINSTALL = $(GOCMD) install
    GOTEST = $(GOCMD) test
    .PHONY: all
    all: build
        GOOS=linux $(GOBUILD) -o netverify ./go/src/
        docker build -t eirwin/netverify -f ./ .
        docker run -t eirwin/netverify /bin/true
        docker cp `docker ps -q -n=1`:/netverify .
        chmod 755 ./netverify
        docker build --rm=true --tag=eirwin/netverify -f Dockerfile.static .
    run:    builddocker
        docker run -p 8282:8282 eirwin/netverify    

    For the purpose of this post, lets assume I have the following as my golang application.

    func main() {
        router := mux.NewRouter()
        router.HandleFunc("/ping", api.PingHandler).Methods("GET")
        http.ListenAndServe(":8282", router)

    When I run Make run everything seems to work except for when the image is ran.

    I can see that the image builds correctly at ~8.5MB

    eirwin/netverify  latest  eae16e146b91 3 seconds ago       8.63 MB

    But when If docker run -p 8282:8282 eirwin/netverify is ran I get the following error…

    docker: Error response from daemon: Container command '/netverify' not found or does not exist..

  • Setting Rails Environment for Apache by Environment Variable
  • Connection refused with kubectl on EC2 ubuntu instance?
  • Docker Remote API returns 500 error on create container
  • How to test code that works with Docker?
  • Why is Play application not able to resolve dependencies from inside docker container?
  • my daemon docker container doesnt stay running
  • One Solution collect form web for “Static Go Binaries w/ Docker – Entrypoint Not Found”

    The go static build in your makefile is missing some options.

        CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -a -installsuffix cgo -o netverify ./go/src/

    The build process can capture the container ID to avoid timing issues.
    Separate the tags for build and binary images.

        docker build -t eirwin/netverify-build -f ./ .
        CID=$$(docker create eirwin/netverify-build); \
        docker cp $$CID:/netverify .; \
        docker rm $$CID
        chmod 755 ./netverify
        docker build --rm=true --tag=eirwin/netverify -f Dockerfile.static .

    Your binary Dockerfile.static can start with the scratch blank image.

    FROM scratch
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.