Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cohenaj194 opened this issue Jul 7, 2016 · 16 comments

Comments

@cohenaj194
Copy link

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
@cohenaj194 cohenaj194 changed the title Registrator will not create services for the new docker services. Registrator will not create services for the docker 1.12 service containers. Jul 7, 2016
@cohenaj194 cohenaj194 changed the title Registrator will not create services for the docker 1.12 service containers. Registrator will not create consul services for the docker 1.12 service containers. Jul 7, 2016
@jeinwag
Copy link

jeinwag commented Jul 11, 2016

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

@bitsofinfo
Copy link

@jeinwag
Copy link

jeinwag commented Jan 9, 2017

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

@sitamet
Copy link

sitamet commented Feb 2, 2017 via email

@logankoester
Copy link

@sitamet Solved my problem, thank you :-)

@pipozzz
Copy link

pipozzz commented Mar 22, 2017

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.

@sulphur
Copy link

sulphur commented May 4, 2017

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

@sitamet
Copy link

sitamet commented May 4, 2017

@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

@sulphur
Copy link

sulphur commented May 5, 2017

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

@gabrielfsousa
Copy link

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

@gabrielfsousa
Copy link

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

@marzlarz
Copy link

marzlarz commented Dec 5, 2017

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 !

@sumanthjoel
Copy link

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).

@xiaods
Copy link

xiaods commented Sep 16, 2018

any update?

@ionosphere80
Copy link

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"

@rash805115
Copy link

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests