gliderlabs / registrator

Service registry bridge for Docker with pluggable adapters
http://gliderlabs.com/registrator
MIT License
4.66k stars 912 forks source link

I wanted to raise your attention to some things i found out that might be helpful #353

Open devotox opened 8 years ago

devotox commented 8 years ago
    registrator:
        container_name: registrator
        image: gliderlabs/registrator
        command: -ip $DOCKER_HOST_IP -resync 60 consul://consul:8500
        volumes:
            - /var/run/docker.sock:/tmp/docker.sock
        depends_on:
            - consul
        links:
            - consul
        env_file:
            - ./shared/dev.env
    consul:
        container_name: consul
        command: -data-dir /data -ui-dir /ui -server -bootstrap
        image: progrium/consul
        ports:
            - 53
            - 8301
            - 8302
            - 8400
            - 53/udp
            - 8301/udp
            - 8302/udp
            - 8300:8300
            - 8500:8500
        env_file:
            - ./shared/dev.env
        volumes:
            - ./consul:/etc/consul.d
    consul-template:
        container_name: consul-template
        command: >
            -consul consul:8500
            -template "/etc/nginx/templates/upstream_servers.ctmpl:/etc/nginx/conf.d/upstream_servers.conf"
            -template "/etc/nginx/templates/upstream_stream_servers.ctmpl:/etc/nginx/conf.d/streams/upstream_servers.conf"
        image: masm/consul-template
        volumes:
            - /var/run/docker.sock:/tmp/docker.sock
        volumes_from:
            - server
        depends_on:
            - consul
        links:
            - consul
        env_file:
            - ./shared/dev.env

After a bit of testing and fiddling with a lot of the 3 images settings i have found this configuration out.

This works as part of a compose file. as you can see there was no need for changing the network mode or hacking to get the docker ip.

The key was using the links. This must be an issue in docker compose it self as the network should already allow em to link to those services by name but alas this is not possible it seems at the time from the command option. now the -ip $DOCKER_HOST_IP is the last thing that needs to be taking out for a fully ubiquitous solution and nothing i can think of seems possible so i ask for your help on this part and i can then write up a full solution for others to use

anentropic commented 8 years ago

I'm new to all this... I am wondering why so many ports for consul?

The examples I've seen for running the consul node with docker run look like: -p 8400:8400 -p 8500:8500 -p 8600:53/udp

devotox commented 8 years ago

I believe consul has multiple ports you can pass data into but all different protocols