I am trying to run haproxy in docker by following this article from the haproxy blog. https://www.haproxy.com/blog/haproxy-on-docker-swarm-load-balancing-and-dns-service-discovery/
I am getting the following error Cannot chroot /var/lib/haproxy
hap_haproxy.3.j24pbth7qsup@prox1 | [NOTICE] (1) : New worker #1 (9) forked
hap_haproxy.3.j24pbth7qsup@prox1 | [NOTICE] (9) : haproxy version is 2.4.7-b5e51a5
hap_haproxy.3.j24pbth7qsup@prox1 | [NOTICE] (9) : path to executable is /usr/local/sbin/haproxy
hap_haproxy.3.j24pbth7qsup@prox1 | [ALERT] (9) : [haproxy.main()] Cannot chroot(/var/lib/haproxy).
hap_haproxy.3.j24pbth7qsup@prox1 | [WARNING] (1) : Current worker #1 (9) exited with code 1 (Exit)
Here is my haproxy configuration
global
log fd@2 local2
# log stdout format raw local0 info
chroot /var/lib/haproxy
pidfile /var/lib/haproxy/haproxy.pid
maxconn 4000
user haproxy
group haproxy
stats socket /var/lib/haproxy/stats user haproxy group haproxy mode 660 level admin expose-fd listeners
master-worker
resolvers docker
nameserver dns1 127.0.0.11:53
resolve_retries 3
timeout resolve 1s
timeout retry 1s
hold other 10s
hold refused 10s
hold nx 10s
hold timeout 10s
hold valid 10s
hold obsolete 10s
defaults
timeout connect 10s
timeout client 30s
timeout server 30s
log global
mode http
option httplog
frontend fe_web
bind *:8080
use_backend stat if { path -i /stats }
default_backend be_service
backend be_service
balance roundrobin
server-template nginx- 6 nginx-Service:80 check resolvers docker init-addr libc,none
backend be_service_wrong_case
balance roundrobin
server-template nginx- 6 nginx-service:80 check resolvers docker init-addr libc,none
backend stat
stats enable
stats uri /stats
stats refresh 15s
stats show-legends
stats show-node
I checked the dockerfile of the official image and the path /var/lib/haproxy
is created.
Can someone please tell me what is going wrong ? (edited)