阅读 ENTRYPOINT
的 Dockerfile 文档,我在尝试重写我的命令之一时遇到问题:
今天运行,没有问题:
# Startup
ENTRYPOINT ["/etc/init.d/hook", "/run/apache2/apache2.pid", "/etc/init.d/apache2 start"]
根据各种消息来源,我应该使用 exec 来 fork 我的钩子(Hook)进程,所以我简单地将入口点更改为
ENTRYPOINT ["exec", "/etc/init.d/hook", "/run/apache2/apache2.pid", "/etc/init.d/apache2 start"]
但现在我收到以下错误:
container_linux.go:247: starting container process caused "exec: \"exec\": executable file not found in $PATH"
为什么找不到exec
?这不是内置的 bash 吗?
如果我连接到容器,我可以毫无问题地运行 exec
$ docker exec -it $( docker ps | grep imagename | awk '{print $1}' ) bash
root@f704bfe5d6c6:/# exec echo hi
hi
如何在我的 ENTRYPOINT
指令中使用 exec
?
编辑
这是一个重现错误的 Dockerfile
FROM ubuntu:16.10
ENTRYPOINT ["exec", "echo", "hi"]
最佳答案
尝试使用 ENTRYPOINT ["exec", "/etc/init.d/hook", "/run/apache2/apache2.pid", "/etc/init.d/apache2", "start"]
查看文档
https://docs.docker.com/engine/reference/builder/#/entrypoint
应该也可以
入口点/etc/init.d/hook/run/apache2/apache2.pid/etc/init.d/apache2 start
关于linux - 使用 Dockerfile ENTRYPOINT 找不到 exec,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42031639/