An open API service indexing awesome lists of open source software.

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

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