Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument check in docker-entrypoint.sh #805

Open
saenglert opened this issue Mar 7, 2023 · 2 comments
Open

Argument check in docker-entrypoint.sh #805

saenglert opened this issue Mar 7, 2023 · 2 comments

Comments

@saenglert
Copy link

Hello everyone,
I wondered what the reasoning behind the argument check in the docker-entrypoint script for the apache and fpm images is:

...
if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
...

As far as I can tell, all images use either apache2-foreground or php-fpm as command, so the check seems redundant.

I stumbled upon this as I was trying to run a script between the entry point and the command. When using this solution, the image's own entry point script of course skips the if-clause. After digging a bit more, I found an issue where people get around this by renaming their scripts.

So to me it seems the check should be either removed or replaced with a search for apache2 or php-fpm within all arguments, so people can more easily add custom scripts.

That is, of course, if there is no special reasoning behind this check.

@tianon
Copy link
Member

tianon commented Mar 7, 2023

The reasoning is that we don't want to cause unexpected behavior for users who are running other things in the image (https://github.com/docker-library/official-images#consistency) -- if a user runs bash, they should expect that it runs bash and other behavior is typically unexpected.

What we suggest in cases like you describe is having the script run before the image's entrypoint instead of after (ie, my-script.sh docker-entrypoint.sh apache2-foreground instead of docker-entrypoint.sh my-script.sh apache2-foreground).

@saenglert
Copy link
Author

I understand the idea, but then what's the point of a WordPress image that doesn't contain WordPress when I start it? I can see use cases where I want to start a bash as soon as the container is ready, but they all require a working WordPress instance, which is why I use the image in the first place.

run before the image's entrypoint instead

That's explicitly not what the people aim to do in the issues I link. They want firstly a working WordPress instance and then run their own script. In my case, I want to install plugins via wp-cli, which I can't do before WordPress is installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants