donglian2106 2017-11-30 07:18
浏览 1091
已采纳

启动docker映像时出现standard_init_linux.go:178错误

I built the docker image using following Dockerfile with Drone build server.

FROM centurylink/ca-certs

WORKDIR /app

ADD VERSION .
ADD conf/ conf/
ADD resources/ resources/
ADD app app

# Expose the application on port 8080
EXPOSE 80

ENTRYPOINT ["./app"]

However it results in the exception standard_init_linux.go:178: exec user process caused "no such file or directory"

Docker host is MacOS. And I'm trying to execute this image in Amazon EC2 linux instance.

Following is the drone build script. (.drone.yml)

workspace:
 base: /go
 path: src/github.com/me/app

pipeline:
 build:
   image: instrumentisto/glide
   commands:
     - glide install
     - export GOOS=linux
     - export GOARCH=amd64
     - go build
     - go test -v 
   when:
     event: [ push, tag ]

 publish:
   image: plugins/ecr
   repo: 111.dkr.ecr.eu-central-1.amazonaws.com/app
   registry: 111.dkr.ecr.eu-central-1.amazonaws.com
   dockerfile: Dockerfile
   tag: ${DRONE_TAG}
   default_tags: false
   default_branch: development
   secrets: [ ecr_access_key, ecr_secret_key, ecr_region ]
   when:
     event: tag
     status: success
     ref: refs/tags/v1*

I've came across similar issues in SO where they suggest to add a shebang line in the script. However in my case the entry point is not a script rather a golang executable.

  • 写回答

1条回答 默认 最新

  • dongzhuandian3292 2017-11-30 18:01
    关注

    You need to make sure your go app is compiled to be statically linked. If it looks for libc, it won't exist in the container you've selected. With go network calls and cgo you will often get dynamic links to things like libc created. To solution to those are CGO_ENABLED=0 and -tags netgo.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?