Docker Pets is a simple application that's useful for testing out features of Docker Datacenter.
If you are interested in a guide on how to demo Docker Pets on the Universal Control Plane then check out this tutorial.
If you are interested in contributing to Docker pets please check out the Release Notes & Roadmap..
1.0is the primary version that should be used for demos.
2.0is a version with minor visual changes. Use this to demonstrate rolling updates from
brokenis a version that reports a failed healthcheck. Use this version to demonstrate an unsucessful rolling update.
docker-pets can be run as a stateless single-container application or as a multi-container stateful application. The following are the two images used to deploy
chrch/docker-petsis a front-end Python Flask container that serves up random images of housepets, depending on the given configuration
consulis a back-end KV store that stores the number of visits that the
webservices recieve. It's configured to bootstrap itself with 3 replicas so that we have fault tolerant persistence.
Building Pets from Scratch
Pets is hosted on the Docker Hub at
chrch/docker-pets:latest but you can also build it locally with the following steps
$ git clone https://github.com/mark-church/docker-pets $ cd docker-pets/web $ docker build -t docker-pets .
Running Pets as a Single Container, Stateless App
$ docker run -it -p 5000:5000 docker-pets
Running Pets on Docker for Mac/Windows in Development
Docker Swarm can easily be set up to run applications on a single developer laptop. The full app can be brought up to run in the same way it would run in production. We use a compose v3 file to deploy a fully fault tolerant frontend and backend, along with the configurations, secrets, and networks required for the application to run.
This is the full architecture that is deployed when using pets-dev-compose.yml.
$ git clone https://github.com/mark-church/docker-pets ~/docker-pets$ docker -v Docker version 1.13.1-rc1, build 2527cfc ~/docker-pets$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS fd3ovikiq7tzmdr70zukbsgbs * moby Ready Active Leader ~/docker-pets$ docker stack deploy -c pets-dev-compose.yml pets
Pets configuration parameters
web container has several configuration parameters as environment variables:
webwhere to find
db. Service name or
webcontainers in to debug mode. When mounting a volume for code, they will restart automatically when they detect a change in the code. Defaults to off, set to
Trueto turn on.
ADMIN_PASSWORD_FILE: Turns secrets on. If set, will password protect the Admin Console of
web. Set to the full location of the Swarm secret (
/run/secrets/< X >)
- Client Web Access - (dev port
5000, prod URL
/shows the selected Pet
/votedisplays the vote selection
/healthdisplays the application health of the given container
/killtoggles the health off for one of the web servers
- Admin Console - (dev port
7000, prod URL
/displays voting results, redirects to
/loginif secrets are configured
/loginrequests login password
- Consul Backend - (dev port
8500, prod ephemeral port)
/uidisplays Consul server UI
Voting Option Configuration
OPTION_A: Defaults to 'Cats'. Pictures located in
OPTION_B: Defaults to 'Dogs'. Pictures located in
OPTION_C: Defaults to 'Whales'. Pictures located in
Running Ppetsets on Docker UCP in Production
This full length tutorial will show you how to deploy and demo DDC with the pets app.
Production apps have entirely different requirements when it comes to security, deployment, and also security. Fortunately, deployment on Swarm & UCP is very much the same from development to production. Some minor additions to our compose file add in capabilities for secrets and also for L7 load balancing.
This is the full architecture that is deployed when using pets-prod-compose.yml.
$ echo "mysecret" | docker secret create admin_password_v1 - $ docker stack deploy -c pets-prod-compose.yml pets