-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add til about a docker container via cron on the host
- Loading branch information
Showing
1 changed file
with
14 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Run a docker container using cronjob on the host | ||
Sometimes you want to run a docker container on the host at specific times. | ||
E.g. star the container, do whatever it has to do and remove it. | ||
This can be accomplished using cron. | ||
|
||
The following can be added to crontab | ||
|
||
``` | ||
00 10 * * * docker run --rm -v ~/nodescripts:/tmp -w /tmp node /bin/bash -c "node index.js" | ||
``` | ||
|
||
This will run a docker container with the folder nodescripts mounted to /tmp and calls bash to run `node index.js` | ||
|
||
An important note is to not have the `-it` flag otherwise you get "the input device is not a TTY" errors. |