1

I followed the instructions in cosul docker hub documentation to start the server in an Eucalyptus cloud. However other than using local host the Http port is not getting exposed out

export  CONSUL_LOCAL_CONFIG=/root/consul.json

From 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

Putting bind address as 127.0.0.1 is not ever starting the server; Giving the IP adress, the server is starting but bot accessible out. I tried -P and -p 8500:8500 also. Still not able to connect from another machine.

Note that this machine had a private IP as well as public IP.

So I am guessing that is the reason why -net-host is not starting on the bind address Still not clear. Two similar threads I found which may explain this

Docker container doesn't expose ports when --net=host is mentioned in the docker run command

https://github.com/docker/docker/issues/13914

Community
  • 1
  • 1
Alex Punnen
  • 5,287
  • 3
  • 59
  • 71

2 Answers2

0

Thanks to the comment by 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

Client from another machine

curl 10.X.X.X:8500/v1/catalog/services
{"consul":[]}

Edit

If you need to run without ACL for tests

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","server":true}' consul agent -server -bind=127.0.0.1 -client=0.0.0.0 -ui

and

To test

 curl -X PUT -d '{"Datacenter": "dc1", "Node": "bing", "Address": "www.bing.com", "Service": {"Service": "search", "Port": 80}}' myip:8500/v1/catalog/register

(from https://jlordiales.me/2015/01/23/docker-consul/)

Alex Punnen
  • 5,287
  • 3
  • 59
  • 71
0

Why you are not try docker-compose

this is a simple docker.yml file for consul

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
wthamira
  • 2,032
  • 2
  • 21
  • 40