exec not found using Dockerfile ENTRYPOINT

Matt Clark

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"]
Matt Clark

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"]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related