Skip to content

Commit

Permalink
Add til about a docker container via cron on the host
Browse files Browse the repository at this point in the history
  • Loading branch information
Shourai committed Aug 25, 2023
1 parent 3a93874 commit 2d09867
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docker/run-docker-container-via-cronjob-on-host.md
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.

0 comments on commit 2d09867

Please sign in to comment.