A lightweight, Alpine-based Docker image designed to run and manage containers or long-running processes using Supervisor, with built-in support for:
docker exec
wrappers (pexe
&dexe
)- Scheduled log rotation via
logrotate
- Cron support via
cronie
- Clean log management for scalable environments
Registry | Image Name |
---|---|
Docker Hub | docker.io/infocyph/runner |
GitHub Container | ghcr.io/infocyph/runner |
Run any command inside a container:
$ dexe <container_name> <command> [...args]
Example:
$ dexe my-app echo "Hello from inside"
Run PHP inside a container:
$ pexe <container_name> <php_script.php> [...args]
Example:
$ pexe my-php-app artisan migrate
Set the
TZ
environment variable (for your desired timezone)TZ=Your_Desired_Timezone
You can mount any directory inside /global/log
to have its .log
files automatically rotated by the system.
-v $(pwd)/my-custom-logs:/global/log/my-app
- Runs every
${LOGROTATE_INTERVAL}
seconds (default:3600
, manageble using environment variableLOGROTATE_INTERVAL
) - Configs loaded from
/etc/logrotate.d/
- Rotates all files in
/global/log/
(and subdirectories) that end with.log
- Mount your logs to
/global/log
to get rotated daily - Mount your logs to
/global/movelog
to get rotated daily long with old logs getting moved to/global/oldlogs
- Rotated logs go to
/global/oldlogs
— make sure to persist this if you want to retain historical logs:
-v $(pwd)/oldlogs:/global/oldlogs
- Single command running container:
docker run -d \
--name runner \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ./supervisor:/etc/supervisor/conf.d:ro \
-v ./cron-jobs:/etc/cron.d:ro \
-v ./logs/runner:/var/log/supervisor \
-v $(pwd)/logs:/global/log \
-v $(pwd)/movelogs:/global/movelog \
-v $(pwd)/oldlogs:/global/oldlogs \
infocyph/runner
- Mount
/etc/supervisor/conf.d
to add Supervisor processes
Example file:
my-task.conf
[program:my-task] command=/bin/sh -c 'echo Hello World && sleep 60' autostart=true autorestart=true stderr_logfile=/var/log/supervisor/my-task.err.log stdout_logfile=/var/log/supervisor/my-task.out.log [program:schedular] command=pexe MY_PHP_CONTAINER artisan schedule:run autostart=true autorestart=true stderr_logfile=/var/log/supervisor/my-task.err.log stdout_logfile=/var/log/supervisor/my-task.out.log
- Mount
/etc/cron.d
to add cron jobs
Example file:
my-cron
* * * * * root echo "Cron ran at $(date)" >> /global/log/my-cron.log 2>&1
/var/run/docker.sock
allowspexe
anddexe
to run commands inside other containers
MIT © infocyph
- GitHub: https://github.com/infocyph/docker-runner
- Issues: Open an Issue