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

Start crond by Default in Alpine Docker Image #353

Closed
thaxy opened this issue Oct 9, 2017 · 2 comments
Closed

Start crond by Default in Alpine Docker Image #353

thaxy opened this issue Oct 9, 2017 · 2 comments

Comments

@thaxy
Copy link

thaxy commented Oct 9, 2017

Hi,

I try to make sure that the crond process is always running in my container.
I can exec into the running container and just run it in the background by executing crond but if I stop and start the container the process would be gone.

Is there any convenient way so that I could run my cron jobs inside my container?
Someone on stackoverflow suggested me to install the extension pg_cron. But all my problems would be gone if I can make sure that crond is always running.

@tianon
Copy link
Member

tianon commented Oct 9, 2017

I'd agree that pg_cron is the best option if you want the jobs to run in your PostgreSQL container.

Another OK option would be to run the jobs via cron on your host using docker exec.

If you must run crond inside a container, I'd recommend instead using a separate container which runs nothing but crond (and thus Docker can both track its lifecycle, and restart it when/if it fails, the machine restarts, etc). You should be able to connect to the PostgreSQL instance from a second container, but if absolutely necessary, one could use things like --network container:some-postgres in order to join the network namespace of the database container directly.

@tianon
Copy link
Member

tianon commented Oct 9, 2017

In the future, these sorts of questions/requests would be more appropriately posted to the Docker Community Forums, the Docker Community Slack, or Stack Overflow. Thanks!

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