Minimal Python application using Docker and cron
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. |
To launch the app, first build the image, then run the container:
docker build --rm -t python-app .
docker run -t -i --rm --name python-app -v <output-directory>:/output python-app
The <output-directory>
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 <output-directory>
on the host machine and in the /output/
directory inside the container.
To inspect the running container, you can:
docker exec python-app bash -c "ls -l /app/"
ENTRYPOINT
line in the Dockerfile
and re-running the steps above