A Docker-Consul bridge that automatically registers containers with published ports as Consul services.
Although available standalone, docksul is meant to be built-in to the progrium/consul container and not used directly.
As Docker containers are started, docksul will inspect them for published ports and register them as services with Consul. As containers stop, the services are deregistered.
If a container publishes one port, one service will be created. By default, the service will be named after the name of the container. You can override this by setting the environment variable CONSUL_NAME
.
If a container publishes more than one port, a service will be created for each published port. By default, the service will be named using the name of the container and the internal port published. For example docker run -p 8000:80 -p 4443:443 --name foobar progrium/foobar
will result in two services called foobar-80
and foobar-443
, listening on ports 8000
and 4443
respectively.
You can override each port's service name by setting the environment variable CONSUL_{port}_NAME
where port is the internal port. In the previous example, that means CONSUL_80_NAME
and CONSUL_443_NAME
.
All published ports using UDP will produce services with the tag udp
. You can add more tags to a service by setting CONSUL_TAGS
or CONSUL_{port}_TAGS
to a comma-delimited list of tags.
- set check command via environment variable
I originally wanted to solve this problem slightly differently, but discussions on the Consul mailing list made it clear this was in demand. Big credit to Michael Crosby for skydock, as this is what everybody wanted "but for Consul".
This project was made possible by DigitalOcean.
BSD