Public | Automated Build

Last pushed: 10 months ago
Short Description
Docker Demo Python App
Full Description

Docker Demo Python App

Demo setup

Make sure these things are done before you run this demo for the very first time.

  1. Clone this repo onto the demo laptop

    git clone

  2. Make sure Docker for Mac or Docker for Windows is installed.

  3. You will need a second Docker Host. The best example is to use a cloud-based instance. But, you can use a local VM. In either case, you'll need to be able to SSH into the 2nd machine, and you'll need its IP address. Setting up this second machine is outside the scope of this script.

  4. Make sure you have a Docker Hub account. You can sign up for free at

  5. On your local machine make sure you log into docker hub by using the docker login command

  6. Build the catweb-docker image and push it to docker hub. These instructions assume you cloned the repo in step 1 to your home directory, if not adjust the file path accordingly.

     cd ~/docker-demo-apps/catweb-docker
     docker build -t <YOUR DOCKER HUB ID>/catweb-docker:latest .
     docker push <YOUR DOCKER HUB ID>/catweb-docker:latest

    Note: If you get an error saying you need to authenticate, you'll need to log in to Docker Hub. See the previous step

Running the demo

This demo is designed to show a build, ship, run workflow using a simple Flask-based web app, catweb.

The basic flow is run the app run the app locally, modify the web template to show how hot mounting a volume works, build an updated image, push to Docker Hub, then deploy on your second Docker host.

If you've not run the demo before, it is advised to watch the video in the repo to see how to talk through each step.

  1. cd ~/docker-demo-apps/catweb-docker (this location may vary depending on where the repo was cloned to)

  2. Show and explain the Dockerfile and how the app is built, you can also show the source code if you wish. The Dockerfile is the same one used in the slides.

  3. Run the app and mount the local directory into the source code directory in the container

    docker run -d -p 5000:5000 --name catweb -v $(pwd):/usr/src/app <YOUR DOCKER HUB ID>/catweb-docker:latest

  4. Switch into a browser on your local machine and show the app running at http://localhost:5000

  5. Switch back to your terminal and edit the index.html file in the templates directory. Usually I change it by using an attendee's name in the title e.g. "Josephine's Random Cat Gif". Save your changes.

    Note: If you cd into the templates directory to edit the file, make sure to cd back into the catweb-docker directory before rebuilding the image in a few steps

  6. Switch back to the web browser and show how the change you made is immediately reflected in the running container.

  7. Switch back to the terminal and build a new version of the catweb-docker image.

    Note: I usually tag the image w/ the name I used when I edited the index.html file so it's easier to remember which one to deploy

    docker build -t <YOUR DOCKER HUB ID>/catweb-docker:<TAG> .

  8. Push the new image to Docker Hub.

    docker push <YOUR DOCKER HUB ID>/catweb-docker:<TAG>

    Note: If you get an error saying you need to authenticate, you'll need to log in to the Docker Hub. See the setup instructions above.

  1. Explain you're now going to simulate deploying an app to "production" by running catweb-docker on a second machine.

    SSH into your SECOND machine

  2. Run catweb-docker on the SECOND machine:

     docker run -d -p 5000:5000 --name catweb <YOUR DOCKER HUB ID>/catweb-docker:<TAG>
  3. Show catweb running on the 2nd machine by browsing to port 5000 at the IP of the 2nd machine. For instance `

Post Demo Clenup

NOTE Do this after EACH demo

  1. Stop and remove the running catweb container on BOTH machines:

    docker stop catweb
    docker rm catweb
  2. You might also want to remove the version of the image you built in step 7. Again, run the following command on both machines.

     docker rmi <YOUR DOCKER HUB ID>/catweb-docker:<TAG>
Docker Pull Command
Source Repository