Volume mount haproxy socket from HAProxy docker container
NickName:soosap Ask DateTime:2017-07-02T16:48:32

Volume mount haproxy socket from HAProxy docker container

I want to give a peer container access to /var/run/haproxy.sock. Unfortunately, it throws an error when I try to do this through bind mounting with a named volume. Is is possible to share the haproxy.sock with other containers? I assume it is, so I wonder which piece I am missing here. Probably rights - but how to set them correctly?

worker1    | <7>haproxy-systemd-wrapper: executing /usr/local/sbin/haproxy -p /run/haproxy.pid -f /usr/local/etc/haproxy/haproxy.cfg -Ds
worker1    | [ALERT] 182/075644 (6) : Starting frontend GLOBAL: error when trying to preserve previous UNIX socket [/var/run/haproxy.sock]
worker1    | <5>haproxy-systemd-wrapper: exit, haproxy RC=1

I have the following config in haproxy.cfg:

global
    maxconn 8204
    tune.ssl.default-dh-param 2048
    stats socket /var/run/haproxy.sock mode 660 level admin
    stats timeout 30s

I use docker-compose to start my containers in swarm mode:

version: '3.2'

services:
  haproxy:
    image: haproxy:1.7.7
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/home/ubuntu/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro"
      - "socket:/var/run/haproxy.sock:rw"
    ulimits:
      nofile:
        soft: 16479
        hard: 16479
    deploy:
      placement:
        constraints:
          - node.hostname==worker1

volumes:
  socket: {}

Copyright Notice:Content Author:「soosap」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/44869004/volume-mount-haproxy-socket-from-haproxy-docker-container

More about “Volume mount haproxy socket from HAProxy docker container” related questions

Volume mount haproxy socket from HAProxy docker container

I want to give a peer container access to /var/run/haproxy.sock. Unfortunately, it throws an error when I try to do this through bind mounting with a named volume. Is is possible to share the haproxy.

Show Detail

Haproxy in docker container unstable

HI i am facing issue with haproxy in docker container. every time when i build my docker container for HA it will work fine, but after sometime it will stop working by giving below error. Error:- ...

Show Detail

haproxy in docker container

I'm new to docker and haproxy.. I tried to follow the example from the official docker hub repo. So, I have Dockerfile FROM haproxy:1.5 COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg and s...

Show Detail

haproxy logs in a kubernetes container

I'm trying to run haproxy in a container deployed by kubernetes but it won't start from my entry script, when I logged into the container and tried to start it by hand I get: [ALERT] 021/125902 (99...

Show Detail

Running Haproxy in docker container

I am trying to create a Docker container from haproxy image but I run in to some problems. I followed the tutorial from Dockerhub where it says to create a Dockerfile containing FROM haproxy:1.7

Show Detail

haproxy zero downtime in docker

I use haproxy and achieve zero downtime using "expose-fd listeners" feature. When I use haproxy docker, container gives error because of line "stats socket /run/haproxy/admin.sock mode 660 level ad...

Show Detail

Running haproxy in foreground on docker container

Previously, I have been using haproxy on the server manually. In that time, I used the command &quot;sudo service haproxy start&quot; to make the haproxy running. The haproxy.cfg was dynamically up...

Show Detail

HAProxy 1.8 - Passing socket connection during HAProxy soft reload

I am using kubernetes load-lanacer(Here the haproxy configuration is written in every 10s and restarted). Since I want to pass the socket connection while reloading the HAProxy, I changed the Docke...

Show Detail

`openssl` not working on `haproxy` docker image

I'm writing a docker container to spin haproxy for load balancing. this is my Dockerfile: FROM haproxy:1.8 ENV DOCKER_IMAGE haproxy ENV DOCKER_NAME loadbalancer ENV TZ Africa/Tunis ENV DOMAINS=&q...

Show Detail

Using variable file w/ haproxy docker container

Im trying, unsuccessfully, to run the official haproxy container (https://hub.docker.com/_/haproxy) with an environment file per (something like this https://www.loadbalancer.org/blog/how-to-install-

Show Detail