Run the ubuntu docker image
docker run -i -t ubuntu /bin/bash
Clone image locally
git https://github.com/itabara/node-docker-sample.git
Build the app docker image
cd node-docker-sample/src
sudo docker build -t node-docker-sample .
Create logs dir into host
sudo mkdir /mnt/logs
docker run -d -v /mnt/logs/:/logs -p 80:80 node-docker-sample
docker ps
Quick test
curl localhost:80
Inspect the container
docker ps
docker inspect <container_id>
curl http://ip:8081
Stop current instance
docker stop <container_id>
Scale out: start two instances of app
docker run -d -v /mnt/logs/:/logs -p 81:80 node-docker-sample
docker run -d -v /mnt/logs/:/logs -p 82:80 node-docker-sample
ps aux | grep node
Build haproxy image
cd haproxy
docker build -t haproxy .
Start the haproxy
docker run -d -v /mnt/logs/:/logs -p 80:80 haproxy
curl http://localhost
ifconfig /all -> get ip of localserver
Attach to the haproxy running image
docker exec -i -t <container_id> bash
vim /opt/haproxy-1.5.3/haproxy.cfg
##replace the 127.0.0.1 with server ip
Supervisorctl
supervisorctl
restart haproxy
curl http://localhost:80
Let's stress our app:
sudo apt-get install apache2-utils
ab -n 10000 -c 10 http://localhost/