title: How do I reload haproxy.cfg on the default Dockerfile?
body: <p>I'm using the default HAProxy Docker image from <a href="https://github.com/dockerfile/haproxy" rel="noreferrer">https://github.com/dockerfile/haproxy</a></p>
  
  <p>Unfortunately I can't get it to reload my config properly. </p>
  
  <p>If I run </p>
  
  <pre><code>$ sudo docker exec haprox haproxy -f /etc/haproxy/haproxy.cfg -p '$(&lt;/var/run/haproxy.pid)' -st '$(&lt;/var/run/haproxy.pid)'
  </code></pre>
  
  <p>it just dumps out the help file. If I run</p>
  
  <pre><code>$ sudo docker exec haprox 'haproxy -f /etc/haproxy/haproxy.cfg -p $(&lt;/var/run/haproxy.pid) -st $(&lt;/var/run/haproxy.pid)'
  </code></pre>
  
  <p>I get </p>
  
  <pre><code>2014/12/30 00:03:23 docker-exec: failed to exec: exec: "haproxy -f /etc/haproxy/haproxy.cfg -p $(&lt;/var/run/haproxy.pid) -st $(&lt;/var/run/haproxy.pid)": stat haproxy -f /etc/haproxy/haproxy.cfg -p $(&lt;/var/run/haproxy.pid) -st $(&lt;/var/run/haproxy.pid): no such file or directory
  </code></pre>
  
  <p>Boo. None of those things are what I want. I <em>can</em> run <code>docker exec haprox service haproxy reload</code> - but this ends out spawning several haproxy processes, so when I connect via the unix socket I get one set of information from <code>show stat</code> but I get an entirely different set of information from the http stats page. </p>
  
  <p>I'm trying to set it up so that I can do graceful redeploys of our legacy software, but it does very <em>very</em> bad things with Tomcat sessions, so my only option is to keep existing sessions alive and pinging the same server.</p>
  
  <pre><code>backend legacy
      cookie SERVERID insert indirect preserve
      server A 123.0.0.123:8080 cookie A check
      server B 123.0.0.123:8080 cookie B check
  </code></pre>
  
  <p>does the trick. I can call up the socket and run <code>set weight legacy/A 0</code> and it will drain connections from server A.</p>
  
  <p>But (remember that legacy part?) I have to bop my server A/B containers on the head and bring up new ones. I've got my system setup where I'm generating the new config just fine, but when I reload... strange things happen.</p>
  
  <p>As mentioned earlier, it ends out spawning several haproxy processes. I get different information from the stats page and the unix socket. It also appears that the pid file of the process that I'm communicating with in the browser vs. socat are different.</p>
  
  <p>Worst of all, though, is that it will stop http connections with a 503 - and using <a href="http://httpd.apache.org/docs/2.2/programs/ab.html" rel="noreferrer"><code>ab</code></a> to test will report some dropped connections. This part is not OK.</p>
  
  <p>Old sessions MUST continue to function until the old server goes down/cookies are cleared. It seems like the rest of the Internet is able to do what I'm trying to do... What am I doing wrong here?</p>