我按照cosul docker hub documentation中的说明在Eucalyptus云中启动服务器。但是,除了使用本地主机之外,Http端口不会暴露出来
export CONSUL_LOCAL_CONFIG=/root/consul.json
来自1
docker run -d --net=host -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true}' consul agent -server -bind=127.0.0.1 -bootstrap-expect=1
将绑定地址设置为127.0.0.1并不会启动服务器;提供IP地址,服务器正在启动,但可以访问机器人。我也试过-P和-p 8500:8500。仍然无法从另一台机器连接。
请注意,此计算机具有私有IP和公共IP。
所以我猜这就是为什么-net-host没有在绑定地址上启动的原因 还不清楚。我找到的两个类似的线程可以解释这个
Docker container doesn't expose ports when --net=host is mentioned in the docker run command
答案 0 :(得分:0)
感谢Rishiloyola的评论
docker run -d -p 8400:8400 -p 8500:8500/tcp -p 8600:53/udp -e 'CONSUL_LOCAL_CONFIG={"acl_datacenter":"dc1","acl_default_policy":"deny","acl_down_policy":"extend-cache","acl_master_token":"the_one_ring","bootstrap_expect":1,"datacenter":"dc1","data_dir":"/usr/local/bin/consul.d/data","server":true}' consul agent -server -bind=127.0.0.1 -client=0.0.0.0
来自其他计算机的客户
curl 10.X.X.X:8500/v1/catalog/services
{"consul":[]}
修改
如果您需要在没有ACL的情况下运行测试
docker run -d -p 8400:8400 -p 8500:8500 / tcp -p 8600:53 / udp -e ' CONSUL_LOCAL_CONFIG = {" bootstrap_expect":1," DATA_DIR":" /usr/local/bin/consul.d/data",&#34 ;服务器":真}' consul agent -server -bind = 127.0.0.1 -client = 0.0.0.0 -ui
和
测试
curl -X PUT -d '{"Datacenter": "dc1", "Node": "bing", "Address": "www.bing.com", "Service": {"Service": "search", "Port": 80}}' myip:8500/v1/catalog/register
答案 1 :(得分:0)
为什么你不尝试使用docker-compose
这是consul的简单docker.yml文件
version: '2'
services:
consul:
container_name: consul
hostname: consul
image: progrium/consul
volumes:
- /data
- /config
- ./consul/consul_ui:/ui
ports:
- "8300:8300"
- "8400:8400"
- "8500:8500"
- "8600:8600"
environment:
- DOCKER_IP=$DOCKER_IP
command: -server -bootstrap -data-dir /data -ui-dir /ui