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

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

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!