首页 > 解决方案 > 每次我想运行时,我的 HAproxy 容器都会退出

问题描述

每次我尝试运行它时,我的 HAproxy 容器都会退出。

我试图在没有 --d 的情况下运行它以查看它退出的原因,并得到以下输出:

$ sudo docker run  --name=hapr -p 80:80 -v /haproxy/:/usr/local/etc/haproxy/  haproxy

我得到这个输出:

HA-Proxy version 2.1.4 2020/04/02 - https://haproxy.org/ Status: stable branch - will stop receiving fixes around Q1 2021. Known bugs: http://www.haproxy.org/bugs/bugs-2.1.4.html Usage : haproxy [-f <cfgfile|cfgdir>]* [ -vdVD ] [ -n <maxconn> ] [ -N <maxpconn> [ -p <pidfile> ] [ -m <max megs> ] [ -C <dir> ] [-- <cfgfile>* -v displays version ; -vv shows known build options. -d enters debug mode ; -db only disables background mode. -dM[<byte>] poisons memory with <byte> (defaults to 0x50) -V enters verbose mode (disables quiet mode) -D goes daemon ; -C changes to <dir> before loading files. -W master-worker mode. -q quiet mode : don't display messages -c check mode : only check config files and exit -n sets the maximum total # of connections (uses ulimit -n) -m limits the usable amount of memory (in MB) -N sets the default, per-proxy maximum # of connections (0) -L set local peer name (default to hostname) -p writes pids of all children to this file -de disables epoll() usage even when available -dp disables poll() usage even when available -dS disables splice usage (broken on old kernels) -dG disables getaddrinfo() usage -dR disables SO_REUSEPORT usage -dr ignores server address resolution failures -dV disables SSL verify on servers side -sf/-st [pid ]* finishes/terminates old pids. -x <unix_socket> get listening sockets from a unix socket -S <bind>[,<bind options>...] new master CLI

如果我列出容器,我会收到以下消息:

$ docker container ls -a

Exited (1) 3 minutes ago

标签: dockerdockerfilecontainershaproxy

解决方案


我已经解决了我的问题,如果有人遇到同样的问题。所以你应该在你的命令中有完整的路径。代替

$ sudo docker run  --name=hapr -p 80:80 -v /haproxy/:/usr/local/etc/haproxy/  haproxy

利用

$ sudo docker run  --name=hapr -p 80:80 -v /home/ubuntu/haproxy/:/usr/local/etc/haproxy/  haproxy

你也应该在你的主机中准备好 haproxy.cfg 。


推荐阅读