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

Add before-start-server script execution #326

Closed
wants to merge 1 commit into from

Conversation

luiscoms
Copy link
Contributor

It should fix #147

In your Dockerfile just add your script

COPY before-start-server.sh /usr/local/bin/

@tianon
Copy link
Member

tianon commented Aug 20, 2018

Have you looked at using #142 for what you need?

@luiscoms
Copy link
Contributor Author

No, in my case, I install cron inside container and I need to start it before start server

@tianon
Copy link
Member

tianon commented Aug 24, 2018

I'd really recommend trying to run crond in a separate container (using --volumes-from or similar to share the WordPress volume), but you should be able to accomplish what you're trying to do already via a command which fires up crond in the background before running this image-provided entrypoint script.

@luiscoms
Copy link
Contributor Author

luiscoms commented Sep 3, 2018

It could be a good approach, but this MR is useful yet

@yosifkit
Copy link
Member

yosifkit commented Sep 4, 2018

Basically the same response as docker-library/mongo#298 (comment); just swap MongoDB related items to Apache/PHP and WordPress appropriate paths, files, or actions:

This is unnecessary since you can already hook a script to run before the entrypoint by running it before the entrypoint:

COPY my-setup-script.sh /docker-entrypoint-extras.d/my-setup-script.sh
# could also just be CMD if you want to put your mongod args into the file
ENTRYPOINT ["/docker-entrypoint-extras.d/my-setup-script.sh"]
CMD ["docker-entrypoint.sh", "--keyFile", "/path/to/keyfile"]

Contents of my-setup-script.sh:

#!/usr/bin/env bash

# pre-mongod setup 
chmod 400 /path/to/keyfile

# ie: docker-entrypoint.sh --keyFile /path/to/keyfile
exec "$@"

From related issue docker-library/mysql#312 (ie, running cron in same container as X).

Be warned that if cron ever crashes there would be nothing in the container that would restart it. It would be better to use a second container that just runs cron, or the host cron that does a docker exec, or add a process supervisor like supervisord.

Other related issues: docker-library/php#248, docker-library/php#301, docker-library/php#409, docker-library/owncloud#49

@yosifkit yosifkit closed this Sep 4, 2018
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

Successfully merging this pull request may close these issues.

Hook in to specific point in entrypoint script
3 participants