Official Wordpress "docker-entrypoint.sh" is run from a custom shell script, throughs an error:
/usr/local/bin/docker-entrypoint.sh: line 26: $1: unbound variable
Line points to:
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then in https://github.com/docker-library/wordpress/blob/master/docker-entrypoint.sh
Steps to reproduce:
...
entrypoint: custom-entrypoint.shsed -i -e 's/^exec "$@"/#exec "$@"/g' /usr/local/bin/docker-entrypoint.sh
source docker-entrypoint.sh
exec "$@"
What's different is the arguments provided -- in the image as-is, we don't run docker-entrypoint.sh by itself, but rather pass apache2-foreground or php-fpm to it (depending on which variant we're using). So the final command is something more like docker-entrypoint.sh apache2-foreground.
That what I was missing... Thanks ! I ended up forking the dockerfile and related docker-entrypoint.sh, and added what I need.
Can you explain to me in simple words what this gibberish means:
sed -i -e 's/^exec "$@"/#exec "$@"/g' /usr/local/bin/docker-entrypoint.sh although I'm no longer using it, had a hard time understanding it. Where does it search for exec in ? what does it replace ? Why ?
That line searches for a line that starts with exec "$@" in the existing entrypoint script and comments it out so that it doesn't run. That exec line will actually _run_ the arguments to the script after it executes, rather than simply running the initialization steps.
Oh.. simple way of extending the shell script. Thanks
Just some background info for others who find this thread:
The basic problem is that if the base image defines BOTH CMD and ENTRYPOINT, your image also has to override both. You can't just override ENTRYPOINT and then keep/inherit CMD. The docs say:
Note: If CMD is defined from the base image, setting ENTRYPOINT will reset CMD to an empty value. In this scenario, CMD must be defined in the current image to have a value.
Source: https://docs.docker.com/engine/reference/builder/#entrypoint
Most helpful comment
Just some background info for others who find this thread:
The basic problem is that if the base image defines BOTH
CMDandENTRYPOINT, your image also has to override both. You can't just overrideENTRYPOINTand then keep/inheritCMD. The docs say:Source: https://docs.docker.com/engine/reference/builder/#entrypoint