dongyi9484 2017-02-14 08:32
浏览 178
已采纳

在docker容器中生成一个新进程,该进程从头开始构建

I'm trying to build a minimal docker image (FROM scratch) that contains 2 executable binaries. Both are binaries built with Go. The entrypoint is set to the first one. It takes some data on the image, transforms it using environment variables, starts a new process executing the second binary and pipes the data as an input for the spawned process.

FROM scratch
COPY bin /opt/my-app
ENTRYPOINT ["/opt/my-app/first", "--run", "/opt/my-app/second"]

When I build this image on my Mac, everything works fine. But when it's created it on our build server running linux, the first process cannot start the second one. It fails with an error "fork/exec /opt/my-app/second: no such file or directory". However, "second" binary does exist. In both cases docker engine 1.13.1 is used.

It also works if parent image is changed from scratch to debian:jessie.

Are there any limitations of the scratch image that I'm not aware of?

  • 写回答

1条回答 默认 最新

  • dongyou5068 2017-02-14 09:47
    关注

    With a scratch image there will not be a libc (or any shared libs). If it works fine on debian, then I suspect the binary is not statically linked, which is the normal default. Try CGO_ENABLED=0 go build -a -installsuffix cgo as seen here http://www.blang.io/posts/2015-04_golang-alpine-build-golang-binaries-for-alpine-linux/

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

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀