Docker4Python — docker-based stack for Python local development
Probably that’s the last major piece we missed in Docker4X projects. We’re glad to end the year by introducing the last addition to Docker-based stacks for most popular and widely adopted script languages — Docker4Python. You can find a quick start guide in our documentation or by using a short alias wodby.com/docker4python.
Like Ruby and unlike PHP, Python packages may require compilation (e.g. psycopg2 PostgreSQL client requires quite a few dev packages), hence can’t be pre-compiled to save time and requires a build step. That’s why our -dev
version of python image contains a bunch of dev packages and in the root of the project, you’ll find Dockerfile that used to build your packages, by default it uses requirements.txt
but if you prefer pipenv
just uncomment the corresponding lines to copy your Pipfile
, Pipfile.lock
files and run pipenv install
instead of pip
. You can also change the command, by default we run Gunicorn HTTP server that you can tune with $GUNICORN_
environment variables.
Once your python image is built docker-compose will start all containers with your codebase mounted so you can update files from your host machine without rebuilding it every time (except when your packages change). If you’re a macOS user and worry about the poor performance of bind mounts we have a couple of options how to fix that.
For Django users, we have snippets in the documentation for quickly connecting to a Database server and Redis for cache storage (django-redis
package). Our Nginx container has configurable locations for static and media files.
If you need to run multiple Python projects we’ve got you covered!
You’re also welcomed to use our images in production, although they definitely require some adjustments to suit production requirements.
The project is currently in the beta so if you find something missing or buggy we encourage you to submit a new issue on GitHub.