1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

docker run / exec でコマンドが実行できない場合は entrypoint を上書き or 削除してみる ( #docker )

Last updated at Posted at 2019-10-14

なぜか echo ok が実行できない

$ docker run mesosphere/aws-cli echo ok
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
...

元のDockerfileを確認する

ENTRYPOINTが指定されている。

image

entrypoint を削除して コマンドを実行する例

$ docker run --entrypoint= mesosphere/aws-cli echo ok
ok

entrypoint を上書きする例

$ docker run --entrypoint='hostname' mesosphere/aws-cli
e2ff1cabebf0

ところで entrypoint のコマンドには引数を渡せないっぽい?

command との違いはなんだろうと思っていたけれど、引数のないコマンド一個だけを実行するということだろうか。なるほど。その名の通りエントリーポイント。

$ docker run --entrypoint='echo ok' mesosphere/aws-cli
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"echo ok\": executable file not found in $PATH": unknown.
ERRO[0001] error waiting for container: context canceled

Dockerfileでは

ENTRYPOINT []

docker - How to remove entrypoint from parent Image on Dockerfile - Stack Overflow

docker-compose では

こうかな。

entrypoint: []

Original by Github issue

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

1
2
0

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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?