gliderlabs/registrator

Registrator will not create consul services for the docker 1.12 service containers.

cohenaj194 opened this issue · 16 comments

This mainly an issue related to the newest version of docker (docker 1.12) and the new version of docker swarm. It has most likely occurred because this project is not up to date with the experimental version of docker. The newest version of docker has a built in version of swarm that deploys containers as docker services. These containers are not directly connected to ports on the swarm worker nodes and as such are not discovered by registrator. Instead they require a docker network, which automatically load balances any containers of a service on a server through a single pre-defined port. So all the containers are essentially attached to the same port, but indirectly so. Right now registrator is not discovering either the containers or the load balanced port.

Here is an example for recreating a docker service that fails to be registered by registrator:

docker network create -d overlay mynet
docker service create –name frontend –replicas 5 -p 80:80/tcp –network mynet nginx

Currently, creation of services isn't exposed through events, so I don't think there's anything that can be done until docker provides such events. It looks like it's already on the roadmap, though: moby/moby#23827

With Docker 1.13, services have the ability to publish ports in host mode (the same as with standalone containers).

@sitamet Solved my problem, thank you :-)

Hi, I have registered service but heath check is failing, could you give me some directions ?

I would like to register service to consul and be able to handle request to this service from fabio.

Thanks in advance.

anyone find a method to do this with @sitamet method

docker service create --container-label SERVICE_6379_NAME=wp-redis -p 6379:6379 --network stackdemo_my-net redis

i get this in registrator :

2017/05/04 11:32:55 ignored: afb4eab7e999 port 6379 not published on host

@sulphur If you don't expose your ports to the host, run registrator with the option to register "the exposed" ports:

-internal		Use exposed ports instead of published ports

normally i expose them(unless i do it wrong :) ) i will try the internal that should fix my problem for non-exposed containers :) thanks

dont work for me :(

docker service create --name tomcat_PROD --container-label SERVICE_8030_NAME=tomcat_PROD -p 8030:8030/tcp --mount type=bind,source=/mnt/tomcat_PROD/conf,target=/opt/tomcat/conf --mount type=bind,source=/mnt/tomcat_PROD/redouteapps,target=/opt/tomcat/redouteapps --mount type=bind,source=/mnt/tomcat_PROD/logs,target=/opt/tomcat/logs --replicas=4 docker01:5000/centos_java8_tomcat8.5.16

with option -internal works,
whats the downsize of using -internal ?

It looks like swarm events are now available as of Docker 17.06: moby/moby#23827

Having registrator pick up docker services would be extremely useful !

is registrator picking up docker services now?

I faced the same issue as mentioned in this chain. When running as a docker container (using docker run), port information is added properly into Consul registry. But, when running as a service (using docker service create), I can see from the registrator logs that the service is ignored as the port is not published. I tried adding the --container-label option which did not help me. Adding -internal option when starting the registrator worked, but it is registering exposed ports and not the published ports (this is my requirement).

any update?

Registrator seems to work if you use Docker compose file version 3.2 with the "long syntax" for ports. Addition of mode: host seems to make the difference because it causes docker ps on the node running the container to show port information. Also works with ephemeral ports. For example:

version: '3.2'
services:
  web1:
    image: solsson/http-echo:latest
    ports:
      - target: 80
        published: 8081
        mode: host
    environment:
      PORT: 80
      SERVICE_80_NAME: "web1-api"
      SERVICE_NAME: "web1-api"
      SERVICE_TAGS: "web1-tag1"

@ionosphere80 Thanks! your solution works for me. But I am not able to understand why??

Does anyone know what is the default value of "mode" when we set it up normally like below.

ports:
  - '8080:80'

Why does docker stack deploy command not cause docker ps on the node running the container to show port information?