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 seata使用出现报错,其他服务找不到seata
  • ¥15 怎么实现输入一个要删除的数后删除后显示剩余数再输入再删除显示剩余数(语言-c语言)
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection