Solution Resort

Learn, try and share…

Category: Python

Python CMD app like a CRON job in Docker

This Github repository is a boilerplate of a simple Python script called repeatably in a Docker container.

Recently I’ve deployed one of my home projects to ECS (AWS Elastic Container Service) using this approach and it worked seamlessly for over 3 weeks so I decided it’s time to share it. My use case was I needed to fetch some data every minute from a third party API and then send the data over to Kinesis. Google Functions combined with Google AppEngine is obviously one of the approaches (https://cloud.google.com/solutions/reliable-task-scheduling-compute-engine) but I think this approach using Docker is probably equally straightforward or even simpler.

The idea is very simple and it’s basically calling a Python script using a fixed interval in a bash script. The reason for using a shell script is that it’s not limited to just Python, but anything can be executed from the command line.

OK, give it a try and let me know how you get on with it 🙂

Install Python 3.6 on Ubuntu 16.04

This should save you some time on finding the right commands to run: https://github.com/shenghuahe/ubuntu1604_python36_installer

Install Docker on Ubuntu 16.04

Feel free to grab: https://github.com/shenghuahe/ubuntu1604_docker_installer

Powered by WordPress & Theme by Anders Norén