All Projects → vegasbrianc → Docker Compose Demo

vegasbrianc / Docker Compose Demo

Licence: apache-2.0
A short demo on how to use Docker Compose to create a Web Service connected to a load balancer and a Redis Database.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Docker Compose Demo

Golang For Nodejs Developers
Examples of Golang compared to Node.js for learning
Stars: ✭ 2,698 (+1505.95%)
Mutual labels:  howto, demo
Opendevops
CODO是一款为用户提供企业多混合云、一站式DevOps、自动化运维、完全开源的云管理平台、自动化运维平台
Stars: ✭ 2,990 (+1679.76%)
Mutual labels:  demo, docker-compose
Jekyll Serve
Jekyll in a Docker Container For Easy SSG Development
Stars: ✭ 164 (-2.38%)
Mutual labels:  docker-compose
Android Demos
Examples of Android applications
Stars: ✭ 1,963 (+1068.45%)
Mutual labels:  demo
Rxdownloader
Demo of Downloading Songs/Images through Android Download Manager using RxJava2
Stars: ✭ 166 (-1.19%)
Mutual labels:  demo
Hole fixer
Demo implementation of smoothly filling holes in 3D meshes using surface fairing
Stars: ✭ 165 (-1.79%)
Mutual labels:  demo
Tonal
A functional music theory library for Javascript
Stars: ✭ 2,156 (+1183.33%)
Mutual labels:  scale
Clean Architecture Swiftui
SwiftUI sample app using Clean Architecture. Examples of working with CoreData persistence, networking, dependency injection, unit testing, and more.
Stars: ✭ 2,925 (+1641.07%)
Mutual labels:  demo
Microservices Sample
Sample project to create an application using microservices architecture
Stars: ✭ 167 (-0.6%)
Mutual labels:  docker-compose
Docker Flask Celery Redis
Docker-Compose template for orchestrating a Flask app with a Celery queue using Redis
Stars: ✭ 165 (-1.79%)
Mutual labels:  docker-compose
Kes
KES is a simple, stateless and distributed key-management system
Stars: ✭ 168 (+0%)
Mutual labels:  scale
An Idiots Guide To Installing Arch On A Lenovo Carbon X1 Gen 6
so you wanted to install arch huh
Stars: ✭ 165 (-1.79%)
Mutual labels:  howto
Mongo Cluster Docker
Docker compose config for mongodb cluster
Stars: ✭ 165 (-1.79%)
Mutual labels:  docker-compose
Vue Ssr
Vue.js Server Side Render Template with Webpack & Express 🐝 🤠
Stars: ✭ 167 (-0.6%)
Mutual labels:  demo
Rhsidebuttons
Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app small side menu. 🌶
Stars: ✭ 164 (-2.38%)
Mutual labels:  demo
Demo
Symfony Demo Application
Stars: ✭ 2,102 (+1151.19%)
Mutual labels:  demo
Cs193p 2017 Fall Demo And Solution
it's slide, demo and assignment of cs193p 2017 fall
Stars: ✭ 164 (-2.38%)
Mutual labels:  demo
Undermoon
Mordern Redis Cluster solution for easy operation.
Stars: ✭ 166 (-1.19%)
Mutual labels:  scale
Docker S3 Volume
Docker container with a data volume from s3.
Stars: ✭ 166 (-1.19%)
Mutual labels:  docker-compose
Sbt Docker Compose
Integrates Docker Compose functionality into sbt
Stars: ✭ 168 (+0%)
Mutual labels:  docker-compose

docker-compose scaling web service demo

A short demo on how to use docker-compose to create a Web Service connected to a load balancer and a Redis Database. Be sure to check out my blog post on the full overview - brianchristner.io

Install

The instructions assume that you have already installed Docker and Docker Compose.

In order to get started be sure to clone this project onto your Docker Host. Create a directory on your host. Please note that the demo webservices will inherit the name from the directory you create. If you create a folder named test. Then the services will all be named test-web, test-redis, test-lb. Also, when you scale your services it will then tack on a number to the end of the service you scale.

git clone https://github.com/vegasbrianc/docker-compose-demo.git .

How to get up and running

Once you've cloned the project to your host we can now start our demo project. Easy! Navigate to the directory in which you cloned the project. Run the following commands from this directory

docker-compose up -d

The docker-compose command will pull the images from Docker Hub and then link them together based on the information inside the docker-compose.yml file. This will create ports, links between containers, and configure applications as requrired. After the command completes we can now view the status of our stack

docker-compose ps

Verify our service is running by either curlng the IP from the command line or view the IP from a web browser. You will notice that the each time you run the command the number of times seen is stored in the Redis Database which increments. The hostname is also reported.

###Curling from the command line

```
curl -H Host:whoami.docker.localhost http://127.0.0.1

Hostname: 2e28ecacc04b
IP: 127.0.0.1
IP: 172.26.0.2
GET / HTTP/1.1
Host: whoami.docker.localhost
User-Agent: curl/7.54.0
Accept: */*
Accept-Encoding: gzip
X-Forwarded-For: 172.26.0.1
X-Forwarded-Host: whoami.docker.localhost
X-Forwarded-Port: 80
X-Forwarded-Proto: http
X-Forwarded-Server: a00d29b3a536
X-Real-Ip: 172.26.0.1
``` 

It is also possible to open a browser tab with the URL http://whoami.docker.localhost/

Scaling

Now comes the fun part of compose which is scaling. Let's scale our web service from 1 instance to 5 instances. This will now scale our web service container. We now should run an update on our stack so the Loadbalancer is informed about the new web service containers.

docker-compose scale whoami=5

Now run our curl command again on our web services and we will now see the hostname change. To get a deeper understanding tail the logs of the stack to watch what happens each time you access your web services.

```
docker-compose logs whoami
whoami_5         | Starting up on port 80
whoami_4         | Starting up on port 80
whoami_3         | Starting up on port 80
whoami_2         | Starting up on port 80
whoami_1         | Starting up on port 80
```

Here's the output from my docker-compose logs after I curled the whoami application so it is clear that the round-robin is sent to all 5 web service containers.

```
reverse-proxy_1  | 172.26.0.1 - - [01/May/2019:19:16:34 +0000] "GET /favicon.ico HTTP/1.1" 200 647 "http://whoami.docker.localhost/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" 10 "Host-whoami-docker-localhost-1" "http://172.26.0.2:80" 1ms
```
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].