LoginSignup
39
17

More than 5 years have passed since last update.

Docker + Goバイナリでstandard_init_linux.go:178: exec user process caused "no such file or directory"と出た時の対処

Posted at

あらまし

以下のようなDockerfileで作られたイメージを実行しようとしたところ、掲題のエラーが出る。
hogebinはGoでビルドされたバイナリ。

Dockerfile
FROM alpine:latest

MAINTAINER kato

WORKDIR /app

COPY hogebin /app

ENTRYPOINT ["/app/hogebin"]

docker logs hogecontainer
=> standard_init_linux.go:178: exec user process caused "no such file or directory"

原因

最近のGoのバイナリはDynamic linkを行うらしく、これはそのリンク対象が存在しないために発生しているらしい。
もしかしたらAlpineを使っているのが原因かもしれない。

対処

hogebinビルド時に、CGO_ENABLED=0をつける。

CGO_ENABLED=0 go build

その他

このエラーメッセージで検索すると、ENTORYPOINTに書かれたコマンドのスクリプトがCRLFが原因のケースが多く出てくるが、
今回はバイナリなので該当しない。

参考

39
17
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
39
17