这是的行为
bash。Docker仍在运行带有外壳的命令,您可以通过检查来识别该外壳:
$ docker inspect test-centos-entrypoint --format '{{.Config.Entrypoint}}'[/bin/sh -c ping localhost]您可以看到/ bin / sh的版本(请注意GNU bash部分):
$ docker exec -it quicktest /bin/sh --versionGNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)Copyright (C) 2011 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
/ bin /
sh的ubuntu版本(可能是破折号)甚至不支持该
--version标志,并且未链接到bash。但是,如果您将ubuntu映像更改为使用bash而不是/
bin / sh,则会看到与centos匹配的行为:
$ cat df.ubuntu-entrypointFROM ubuntu:trustyENTRYPOINT [ "/bin/bash", "-c", "ping localhost" ]$ DOCKER_BUILDKIT=0 docker build -t test-ubuntu-entrypoint -f df.ubuntu-entrypoint .Sending build context to Docker daemon 23.04kBStep 1/2 : FROM ubuntu:trusty ---> 67759a80360cStep 2/2 : ENTRYPOINT [ "/bin/bash", "-c", "ping localhost" ] ---> Running in 5c4161cafd6bRemoving intermediate container 5c4161cafd6b ---> c871fe2e2063Successfully built c871fe2e2063Successfully tagged test-ubuntu-entrypoint:latest$ docker run -d --name quicktest2 --rm test-ubuntu-entrypoint362bdc75e4a960854ff17cf5cae62a3247c39079dc1290e8a85b88114b6af694$ docker exec -it quicktest2 ps -efUID PID PPID C STIME TTY TIME CMDroot 1 0 0 13:05 ? 00:00:00 ping localhostroot 8 0 0 13:05 pts/0 00:00:00 ps -ef



