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

Don't set the hostname to the service name with networking. #2334

Merged
merged 1 commit into from
Nov 10, 2015

Conversation

dnephin
Copy link

@dnephin dnephin commented Nov 5, 2015

Fixes #2327

Since it's not being used for anything, I think we can undo this part of the networking experiment. When we get alias support there should be some other mechanism we can use to set the aliases.

cc @aanand @vieux

Signed-off-by: Daniel Nephin <dnephin@docker.com>
@vieux
Copy link

vieux commented Nov 5, 2015

LGTM

@vieux
Copy link

vieux commented Nov 5, 2015

thanks @dnephin

@vieux
Copy link

vieux commented Nov 5, 2015

@abronan you might want to use this next week.

@abronan
Copy link

abronan commented Nov 5, 2015

Indeed, LGTM.

@aanand
Copy link

aanand commented Nov 10, 2015

LGTM

aanand added a commit that referenced this pull request Nov 10, 2015
Don't set the hostname to the service name with networking.
@aanand aanand merged commit 917b885 into docker:master Nov 10, 2015
@dnephin dnephin deleted the dont_set_hostname branch November 10, 2015 17:34
@okgemaltoprg
Copy link

What if I'd like to have quite opposite? Set hostname to full service name? E.g. test_myapp_1 instead of myapp only? The reason is following:
I have to get exposed dynamic port from within the container to be able to set Hazelcast bind port on public IP.

Previously (Docker 1.8.x), mistakenly using "experimental" /etc/hosts mapping, I could easily connect my container IP with my container name (because it was listed together with the rest of the services running on default subnet) and use it as filter for list of services gathered from Consul.

Now my container could be only uid (default Docker /etc/hosts mapping) or service name (generated by Docker-compose) where neither of it helps discovering my real container name (test_myapp_1) published by Registrator to Consul.
There are multiple ways how to solve it, however none of them is as trivial as the previous one.

Any ideas? Could it be optional?

@dnephin
Copy link
Author

dnephin commented Nov 12, 2015

Does it need to be the container_name? Could it be the unique container id, which you can get from $(hostname) ?

@okgemaltoprg
Copy link

That's the trick - (gliderlabs) Registrator registers IP (default=server/host), container_name, published ports. There's no way (please correct me if I'm wrong) how to force it to register container id (as tag for example).
So, in case there's more than one service running on one host (for HA), one have to filter response from Consul somehow. The only filter available in that case is container_name which is currently unknown again inside the container (talking about production hardened setup, not running on host network or mounting Docker socket, or exposing Docker api).

Previously, I used container name "experimentally" added to /etc/hosts (registered by Registrator in Consul by default) to filter running services on that specific host and get dynamically assigned port as result, then export it as Java variable and start Tomcat.

curl --connect-timeout 1 -m 1 --no-keepalive -sS http://host:8500/v1/health/service/oobs-hazelcast | jq --arg HOST_IP ${HOST_IP} --arg CONTAINER_NAME ${CONTAINER_NAME} -r '.[] | (.Service.Port | tostring) + "-" + .Node.Address + "-" + .Service.ID | select(contains($HOST_IP)) | select(contains($CONTAINER_NAME))'

container_ip=172.17.42.3
/etc/hosts example previously:

172.17.42.3 container_id
::1 localhost whatever
172.17.42.3 container_name_1
172.17.42.4 container_name_2

/etc/hosts example now:

172.17.42:3 container_id (or name when using docker-compose --x-networking)
::1 localhost whatever
17.17.42.4 container_name_2

@dnephin
Copy link
Author

dnephin commented Nov 13, 2015

Ok, this sounds a lot like #1503, let's continue the discussion there

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

Successfully merging this pull request may close these issues.

None yet

6 participants