Cant access consul webui docker compose

﹥>﹥吖頭↗ 提交于 2019-12-11 16:59:57

问题


Im trying to standup consul dev webui for traning purposes using docker compose.

While consul claims to be running, when I try to visit localhost:8500/ui, the site is unreachable.

My docker compose file:

version: "3"
services:

  cs1:
    image: consul:1.4.2
    ports:
      - "8500:8500"
    command: "agent -dev -ui"

The response from the console is

cs1_1_6d8d914aa536 | ==> Starting Consul agent...
cs1_1_6d8d914aa536 | ==> Consul agent running!
cs1_1_6d8d914aa536 |            Version: 'v1.4.2'
cs1_1_6d8d914aa536 |            Node ID: 'dfc6a0ce-3abc-a96d-718b-8b77155a2de6'
cs1_1_6d8d914aa536 |          Node name: '1fde0528ab0c'
cs1_1_6d8d914aa536 |         Datacenter: 'dc1' (Segment: '<all>')
cs1_1_6d8d914aa536 |             Server: true (Bootstrap: false)
cs1_1_6d8d914aa536 |        Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS: -1, gRPC: 8502, DNS: 8600)
cs1_1_6d8d914aa536 |       Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)
cs1_1_6d8d914aa536 |            Encrypt: Gossip: false, TLS-Outgoing: false, TLS-Incoming: false

I suspect the site is running on the docker container locahost but port 8500 hasnt been exposed properly.

Thanks for your help


回答1:


Remove the line command: "agent -dev -ui" from your docker-compose.yml.

The default command is already running the dev agent, see the Dockerfile here:

https://github.com/hashicorp/docker-consul/blob/9bd2aa7ecf2414b8712e055f2374699148e8941c/0.X/Dockerfile




回答2:


By default, the consul is bind to localhost

Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS: -1, gRPC: 8502, DNS: 8600)

add bind to your command usually allowed to any IP (0.0.0.0)

agent -dev -ui -bind=0.0.0.0


来源:https://stackoverflow.com/questions/54796725/cant-access-consul-webui-docker-compose

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!