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

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

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

报告相同问题?

悬赏问题

  • ¥15 网络科学导论,网络控制
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)