use simple demo app, compile to exe file on ubuntu named as demo
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
})
r.Run() // listen and serve on 0.0.0.0:8080
}
```Dockerfile
FROM alpine:latest
RUN apk --no-cache add ca-certificates
ADD demo /bin
CMD [ "demo" ]
build docker image and run
```bash
docker build -t test .
docker run test
result:
standard_init_linux.go:178: exec user process caused "no such file or directory"
if I run the service in ubuntu docker image, there is no such issue.
FROM ubuntu:xenial
ADD demo /bin
CMD [ "demo" ]
Can we make it clear what is missing?
have you ever tried static build? GOOS=linux GOARCH=amd64 go build
why should I try that?
because there is no standard libc in alpine. compile it as suggested.
Thanks for the explaination. I compile on linux(arm64) acutally.
I can run in alpine container by disable cgo finally. (I can run it in scratch docker :))
CGO_ENABLED=0 go build ...
Most helpful comment
Thanks for the explaination. I compile on linux(arm64) acutally.
I can run in alpine container by disable cgo finally. (I can run it in scratch docker :))
CGO_ENABLED=0 go build ...