728x90
반응형
Use HAProxy with Docker
1. Create Dockerfile for HAProxy Build with Docker
1 2 | FROM haproxy:1.7 // Set HAProxy version ADD haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg | cs |
2. Docker build using Dockerfile created
1 | docker build -t my-haproxy . | cs |
3. After you build Dockerfile, you can find docker images that is my-haproxy
1 2 3 | $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE my-haproxy latest 98f53e224010 5 hours ago 134.9 MB | cs |
4. To create HAProxy you should make haproxy.cfg that is configure file for haproxy.
For test I already created two nodes
haproxy.cfg are contained health check
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | global log 127.0.0.1 local0 log 127.0.0.1 local1 notice maxconn 8192 defaults balance roundrobin log global mode tcp option tcplog option redispatch option log-health-checks retries 5 maxconn 8192 timeout connect 50s timeout client 500s timeout server 500s listen stats bind *:1936 mode http stats enable stats uri /stats stats auth guest:guest stats refresh 5s listen web bind *:80
mode http
balance roundrobin
server web1 172.17.0.8:7777 check
server web2 172.17.0.9:7778 check | cs |
- stats
- Set haproxy monitoring
- You can connect [host_ip]:1936/stats and see haproxy web ui
- auth - account ID / account PW
- web
- Bind 80 port.
- balance mode is roundrobin.
- health check for web1, web2.
5. Use haproxy.cfg that you set to run the docker.
1 | docker run -d -p 1936:1936 -p 80:80 --name docker-haproxy my-haproxy | cs |
6. If docker is run well, You can see the stats UI.
Through [host_ip]:1936/stats, You can see web ui below.
728x90
반응형
'Programming > Docker' 카테고리의 다른 글
docker file copy from container to host (0) | 2017.04.03 |
---|---|
Nginx on Docker (0) | 2017.03.30 |
socket.io load balancing with HAProxy on Docker (0) | 2017.03.28 |
docker upgrade (error : The engine version is lesser than the minimum required by compose) (0) | 2016.07.18 |
docker-compose version upgrade (0) | 2016.07.18 |
댓글0