This is a bare minimum Django server app that is wrapped in a Docker image. It is based upon a PyTexas demo by Mark Adams.
Install Docker Git clone this repo
docker build -t demoapp .
The contents of the Dockerfile build script will start with python 3.4
FROM python:3.4
# Set PYTHONUNBUFFERED so output is displayed in the Docker log
ENV PYTHONUNBUFFERED=1
EXPOSE 8000
WORKDIR /usr/src/app
# Install dependencies
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
# Copy the application's code
COPY . /usr/src/app
# Run the app
RUN chmod +x ./run_app.sh
CMD ["./run_app.sh"]
Create and run a container from the image. This will build a container with the tag "demoapp" and the dot indicates the Dockerfile location.
docker build -t demoapp .
docker images
The -ti for "terminal interactive" allows you to use ^C to kill the process. The -p 8000:8000 options indicate the exposedPort:internalPort accessiblility. The express-helloworld option indicates the image name to create a container.
docker run -d -p 8000:8000 demoap
Switch to your browser and get: http://127.0.0.1:8000/
Kill the running process
docker kill [containerId]
List container instances to be removed
docker ps -a
Remove container instances docker rm
docker rm ea0ea
Remove images
docker rmi demoapp
Add to your github repo
git init
git add .
## create your github repo
git remote add origin https://github.com/chrispauley/docker_django.git
git push origin master
Login to your server host. At a terminal window
git clone https://github.com/chrispauley/docker_django.git
cd docker-express
docker build -t demoapp .
docker run -ti -p 8000:8000 demoapp
Make sure your server host port 8000 is accessible and test it: http://192.168.0.84:8000/ Update a cname record on your domain and your up.
Remember to clean up your containers and images!
First tag your image with your hub.docker.com user account name:
docker tag a234b052333a chrispauley/guestbook
docker images
Next, login and push to Docker hub
docker push chrispauley/guestbook
Now you can deploy using a docker pull command on a docker host server. Switch to the docker host machine.
docker run -ti -d -p 8000:8000 chrispauley/guestbook
Test it from your browser and enjoy.
- docker-compose build
- docker-compose up
- docker-compose kill [containerId]
- docker-compose stop [containerId]
- docker-compose rm [containerId]
- docker-compose env
- docker-machine create [hostId]
- creates a new docker host (like on AWS, Rackspace, etc.)
- docker-machine ls
- docker-machine ssh [hostId]
- connects to the host using ssh
- docker-machine rm [hostId]
- destroys a host
- amazonec2
- azure
- digitalocean
- exoscale
- openstack
- rackspace
- softlayer
- virtualbox
- vmwarecloudair
- vmwarevsphere