standard_init_linux.go:190: exec user process caused “no such file or directory” Docker with go basic web app

前端 未结 5 2029
野性不改
野性不改 2020-12-21 07:32

The very basic web app is created in Go

package main

import(
   "fmt"
   "net/http"
   "os"
)

func hostHandler(w http.Response         


        
5条回答
  •  悲哀的现实
    2020-12-21 07:53

    File not found can mean the file is missing, a script missing the interpreter, or an executable missing a library. In this case, the net import brings in libc by default, as a dynamic linked binary. You should be able to see that with ldd on your binary.

    To fix it, you'll need to pass some extra flags:

    CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -ldflags '-w' -o mybin *.go
    

    The above is from: https://medium.com/@diogok/on-golang-static-binaries-cross-compiling-and-plugins-1aed33499671

提交回复
热议问题