This application stack is comprised out of three images
- HA Proxy
- Web Server written in Go (which increases a counter in Redis for every hit)
- Redis KV store
- Install Docker v1.12 experimental
curl -sSL https://experimental.docker.com/ | sh
- Install Docker Compose
curl -L https://github.com/docker/compose/releases/download/1.8.0-rc2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
- Start Docker Service
sudo service docker start
- Ensure that your user is in the Docker group!
sudo usermod -aG docker your-user
- Clone this repo
git clone https://github.com/Tueffy/multitier_docker/
- Build the web image (XYZ your user id)
docker build -t XYZ/webgoredis .
- Modify the docker-compose.yml and replace the web image with the one you have just build, e.g. replacing the user id
- Start the stack
docker-compose up
- Test the stack (HAProxy is listening on port 80) and see the counter increasing
http://yourip
- Play around with scaling
docker-compose scale web=3
- Hit further times in the web browser and you see changing host names
You need three machines for this, all with Docker v1.12 experimental installed. Name the machines: manager, node1 and node2. In my example I used packet.net and got three machines of size Tiny with CentOS 7 on it.
- On the manager initialize the Docker Swarm
docker swarm init --listen-addr <managerip>:2377
Note: ensure that port 2377 is opened in the firewall for accepting connections from the outside, therefore run on the manager
sudo firewall-cmd --zone=public --add-port=2377/tcp --permanent
- Add the two nodes to the Docker Swarm
docker swarm join <managerip>:2377
- Go back to the manager and view the nodes
docker node ls
- If you have not done already in previous tutorial, build the web image and adopt the docker-compose.yml file with the correct name
- In order to create a DAB (Distributed Application Bundle), get the images for redis and lb
docker-compose pull redis
docker-compose pull lb
- And now we create the bundle:
docker-compose bundle --fetch-digests
- Via the new deploy command, the dab file can be deployed to the Swarm and you can give it a name
docker deploy -f multitierdocker.dab mymultitiertest
- After that you can have a look at the created services
docker service ls
- For detailed information on a service, you can look at the tasks (aka deployed containers)
docker service tasks mymultitiertest_web
- And also here you can scale easily
docker service scale mymultitiertest_web=3
That is the most easy one! Ensure that you have an account in cloud.docker.com. Create a node cluster (e.g. also via Packet or AWS) and then just hit the button below: