Reading up on the Dockerfile documentation for ENTRYPOINT
, I am having an issue trying to rewrite one of my commands:
As it runs today, without issues:
# Startup
ENTRYPOINT ["/etc/init.d/hook", "/run/apache2/apache2.pid", "/etc/init.d/apache2 start"]
According to various sources, I should fork my hook process using exec , so I have simple changed the entrypoint to
ENTRYPOINT ["exec", "/etc/init.d/hook", "/run/apache2/apache2.pid", "/etc/init.d/apache2 start"]
But now I receive the following error:
container_linux.go:247: starting container process caused "exec: \\"exec\\": executable file not found in $PATH"
Why can exec
not be found? Is this not a bash builtin?
If I attach to the container, I can run exec without issue
$ docker exec -it $( docker ps | grep imagename | awk '{print $1}' ) bash
root@f704bfe5d6c6:/# exec echo hi
hi
How can I use exec
in my ENTRYPOINT
directive?
edit
Here is a Dockerfile that reproduces the error
FROM ubuntu:16.10
ENTRYPOINT ["exec", "echo", "hi"]
Try with ENTRYPOINT ["exec", "/etc/init.d/hook", "/run/apache2/apache2.pid", "/etc/init.d/apache2", "start"]
check the doc
https://docs.docker.com/engine/reference/builder/#/entrypoint
should also work
ENTRYPOINT /etc/init.d/hook /run/apache2/apache2.pid /etc/init.d/apache2 start
Interestingly, I can make this work by simply removing the parameters from an array
This will work as expected
ENTRYPOINT exec echo hi
While this will generate the error
ENTRYPOINT ["exec", "echo", "hi"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.