Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail to run in alpine docker with error "no such file or directory" #1178

Closed
zhangpy opened this issue Nov 21, 2017 · 4 comments
Closed

fail to run in alpine docker with error "no such file or directory" #1178

zhangpy opened this issue Nov 21, 2017 · 4 comments

Comments

@zhangpy
Copy link

zhangpy commented Nov 21, 2017

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
}
FROM alpine:latest
RUN apk --no-cache add ca-certificates
ADD demo /bin
CMD [ "demo" ]

build docker image and run

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?

@ycdesu
Copy link

ycdesu commented Nov 23, 2017

have you ever tried static build? GOOS=linux GOARCH=amd64 go build

@zhangpy
Copy link
Author

zhangpy commented Nov 27, 2017

why should I try that?

@george-oakling
Copy link

because there is no standard libc in alpine. compile it as suggested.

@zhangpy
Copy link
Author

zhangpy commented Dec 15, 2017

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 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants