Docker-Image to run python webapps mounted as volume.
- Runs as non-root with fixed UID 10777 and GID 10777. See howto prepare volume permissions.
- See howto use SystemD for named Docker-Containers and system startup.
Run the example-app like so.
docker run \
-i -t \
-v $(pwd)/example-app/:/pyapp/web \
-v $(pwd)/data/:/pyapp/data \
-p 8877:8000 \
codeclou/docker-python-web:latest
Now go to http://localhost:8877 and see your app.
Note: Depending on how many dependencies you install, it might take some time until the server starts up.
You can write to /pyapp/data/*
from your application.
Run a commandline app like so
docker run \
-i -t \
-v $(pwd)/example-cli/:/pyapp/web \
-v $(pwd)/data/:/pyapp/data \
codeclou/docker-python-web:latest \
python cli.py
See the example-app and abide the following conventions for your application:
- Have a
requirements.txt
in the root of your project defining your dependencies - Have a
app.py
in the root of your project that starts a server on 8000 and listens on0.0.0.0
- Include the following line in your app to fetch the libs from
extlibs
dirsys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/extlibs/")
- Dockerfile and Image is provided under MIT License