我的問題是我有一個docker-compose.yml
文件和一個haproxy.cfg
文件,我想docker-compose將haproxy.cfg
文件複製到docker容器中。根據帖子Docker composer copy files我可以使用捲來做到這一點,但在我的情況下,我得到了以下錯誤。任何人都可以幫助我實現這一點。Docker-Compose不能複製haproxy.cfg
下面是代碼,一切
泊塢窗,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"
文件夾結構
命令輸出
[email protected]:/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
你不能用docker-compose將一個文件複製到一個容器中。這必須在'Dockerfile'本身完成 – Serey
我沒有文件...我應該使用官方haproxy圖像...有什麼辦法可以做到這一點... – utkarsh31
@Serey我已經完成它之前,看到我的答案 – MatTheWhale