Haproxy in docker container
I am new to docker and haproxy .. I tried to follow the example from the official docker repository .
So I have a Dockerfile
FROM haproxy:1.5
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
and a simple haproxy configurator (which I expect to redirect local calls to my EB instance)
global
# daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:80
default_backend servers
backend servers
server server1 {my-app}.elasticbeanstalk.com:80 maxconn 32
Build and run
$ docker build . $ docker run --rm d4598bcc293f
The container starts and holds, Ctrl + C does not stop it. Docker killer only helps.
My EB resource is up and running
$ curl {my-app}.elasticbeanstalk.com/status
{
"status": "OK"
}
But local calls don't work
$ boot2docker ip
192.168.59.104
$ curl 192.168.59.104/status
curl: (7) Failed to connect to 192.168.59.104 port 80: Connection refused
What am I missing or something amiss?
Thank!
UPDATE: I found a problem with call forwarding. Invalid port number in haproxy.cfg.
But this problem still annoys me ... The container starts and holds, Ctrl + C does not stop. "Docker kill" only helps.
source to share
If you want to be able to exit with control-c, do docker run -i <image>
. -i
means passing input to the container program, and if HAProxy receives control-c then it will abort the action that will stop the container.
HAProxy doesn't produce any output unless you run it in debug mode, so there really aren't many launch links. You may have a better time since docker run -d <image>
detaching from the container and allowing it to run in the background. To stop it, use docker kill
.
source to share