Swarm Consul Notifier

A docker image that keeps Consul notified of service-related Docker Swarm events. It is the (partial) equivalent of Registrator for Docker services.

Notes/HowTo:

Using docker:

docker run -d \
    --name=consul_notifier \
    --net=host \
    --volume=/var/run/docker.sock:/tmp/docker.sock \
    aisaac/swarm-consul-notifier:latest 

Recommended: using docker-compose along with a consul Agent on each node in Docker Swarm:

version: '3'
services:
    consul_agent:
        image: consul
        container_name: consul_agent
        ports:
            - 8300
            - 8301
            - 8301/udp
            - 8302
            - 8302/udp
            - 8400
            - 8500
        environment:
            - "CONSUL_LOCAL_CONFIG={\"leave_on_terminate\" : true}"
        entrypoint:
            - consul
            - agent
            - -node=<node_name>
            - -advertise=<host_ip>
            - -data-dir=<data_dir>
            - -encrypt=<consul_encryption_key>
            - -datacenter=<datacenter_name>
            - -retry-join=<consul_server_url/ip>
        network_mode: "host"

    consul_notifier:
        image: aisaac/swarm-consul-notifier
        container_name: consul_notifier
        depends_on:
            - consul_agent
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
        network_mode: "host"
        labels:

Credits