https://github.com/mloning/minimal-python-app-using-docker-cron
Minimal Python application using Docker and cron
https://github.com/mloning/minimal-python-app-using-docker-cron
cron docker python
Last synced: 5 months ago
JSON representation
Minimal Python application using Docker and cron
- Host: GitHub
- URL: https://github.com/mloning/minimal-python-app-using-docker-cron
- Owner: mloning
- Created: 2021-07-27T08:05:06.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-11-13T16:46:16.000Z (over 3 years ago)
- Last Synced: 2025-04-04T22:11:13.333Z (over 1 year ago)
- Topics: cron, docker, python
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Minimal Python application using Docker and cron
## Overview
| File | Description |
|---|---|
| `Dockerfile` | [Docker] instructions how to build image. |
| `app.py` | [Python] application. |
| `entrypoint.sh` | [Docker] instructions how to run the container. |
| `run.sh` | Bash script to run the application. |
| `schedule.txt` | Configuration for [cron] scheduler. |
[docker]: https://www.docker.com
[python]: https://www.python.org
[cron]: https://en.wikipedia.org/wiki/Cron
## Usage
To launch the app, first build the image, then run the container:
1. `docker build --rm -t python-app .`
2. `docker run -t -i --rm --name python-app -v :/output python-app`
The `` is a directory on the host machine. Use the full, absolute path to specify it. It is used for writing out logs from the application.
The configuration in `schedule.txt` will run the Python script every minute. Logs will saved to the `` on the host machine and in the `/output/` directory inside the container.
To inspect the running container, you can:
* exectute commands inside the container, e.g. `docker exec python-app bash -c "ls -l /app/"`
* run the container in interactive mode by commenting out the `ENTRYPOINT` line in the `Dockerfile` and re-running the steps above