【发布时间】:2018-01-16 08:22:26
【问题描述】:
我的问题是我有一个 docker-compose.yml 文件和一个 haproxy.cfg 文件,我希望 docker-compose 将 haproxy.cfg 文件复制到 docker 容器中。根据Docker composer copy files 的帖子,我可以使用卷来执行此操作,但就我而言,我遇到了以下错误。谁能帮我实现这个目标。
下面是代码和所有内容
docker-compose.yml
version: "3.3"
services:
###After all services are up, we are initializing the gateway
gateway:
container_name: gateway-haproxy
image: haproxy
volumes:
- .:/usr/local/etc/haproxy
ports:
- 80:80
network_mode: "host"
文件夹结构
命令输出
root@ubuntu:/home/karunesh/Desktop/Stuff/SelfStudy/DevOps/docker# docker-compose up
Creating gateway-haproxy ...
Creating gateway-haproxy ... done
Attaching to gateway-haproxy
gateway-haproxy | <7>haproxy-systemd-wrapper: executing /usr/local/sbin/haproxy -p /run/haproxy.pid -f /usr/local/etc/haproxy/haproxy.cfg -Ds
gateway-haproxy | [ALERT] 219/163305 (6) : [/usr/local/sbin/haproxy.main()] No enabled listener found (check for 'bind' directives) ! Exiting.
gateway-haproxy | <5>haproxy-systemd-wrapper: exit, haproxy RC=1
gateway-haproxy exited with code 1
【问题讨论】:
-
你不能
copy使用 docker-compose 将文件放入容器中。这必须在Dockerfile本身内部完成 -
我没有文件...我应该使用官方的haproxy图像...有什么办法可以做到...
-
@Serey 我以前做过,请看下面我的回答
-
@MatTheWhale 是的,不是 100% 确定他想要什么,因为这仅在您安装卷时有用。如果他想在他的环境之外工作,那么如果他想建立,那就不同了。
标签: docker docker-compose haproxy docker-volume docker-copy