Skip to content

Instantly share code, notes, and snippets.

@jsherer
Created July 26, 2017 15:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsherer/ba0b773d540a70dc2eb9bb3fdbf0189e to your computer and use it in GitHub Desktop.
Save jsherer/ba0b773d540a70dc2eb9bb3fdbf0189e to your computer and use it in GitHub Desktop.
Run a Python Project

Python Dockerfile Isolation Runtime

This is defined for Python 3 apps. But, you can change it to run Python 2 by changing the first line of the Dockerfile.

To Run

  1. Copy these files into the project directory
  2. Update run.sh with the commmand(s) to run.
  3. Build the docker image: docker build -t project-name .
  4. Run it! docker run -it --rm --name project-name-running project-name
FROM python:3
WORKDIR /usr/src/app
EXPOSE 80 8000 8080 5000 5001
COPY requirements.txt ./
RUN apt update && apt install -y memcached
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "./run.sh" ]
#!/bin/bash
# run memcache in the background
memcached -u root -m 1000 &
# change this to whatever command specified to run the code
python app.py
@bryanhelmig
Copy link

docker run -it -p 11211:11211 --name mc memcached and docker run -it --link mc -v $(pwd):/app -p 8000:8000 python:3 bash has been helpful for me here too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment