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

simple names in /etc/hosts when using the experimental networking feature #2312

Closed
brianbolt opened this issue Nov 4, 2015 · 6 comments
Closed

Comments

@brianbolt
Copy link

When using the --x-networking feature in docker-compose 1.5 (docker-engine 1.9), is it possible to get a "simple name" added to /etc/hosts without knowing the container name beforehand and without using the container_name directive?

For example, the following compose file in a directory called dockercompose might produce the /etc/hosts entries below:

web:
  image: firstapp
web2:
  image: secondapp

/etc/hosts entries in the auto generated "dockercompose_web_1" container looks like:

172.18.0.2  dockercompose_web2_1
172.18.0.2  dockercompose_web2_1.dockercompose

I was hoping I would see the following entry as well:

172.18.0.2  web2

Let's say the image firstapp is hardcoded to communicate with a host named web2 and secondapp is harcoded to communicate with a host named web. Is it possible to get this circular communication working and maintain the ability to startup multiple instances of the overall app?

@dnephin
Copy link

dnephin commented Nov 4, 2015

Nope, the docker/libnetworking support isn't in yet to provided aliases. As soon as it is, we'll be adding support to compose. The only way to do it right now is with the container_name.

It should be coming in the next release.

@dnephin
Copy link

dnephin commented Nov 5, 2015

I just created moby/libnetwork#737

@brianbolt
Copy link
Author

Follow up question. Using the 1.5.0 release, how is one supposed to use the experiment networking feature without alias'? I have config files for my webapp that tell it that the hostname of the database is "db". I can use the container_name feature but that breaks that ability to startup multiple instances. I just don't get how people are using this feature. Are there any examples in the documentation that could help me? I haven't been able to find any.

@dnephin
Copy link

dnephin commented Nov 6, 2015

There is one example in #2294, where you can set the project name using COMPOSE_PROJECT_NAME and pass it as an environment variable to the containers.

@dnephin
Copy link

dnephin commented Nov 13, 2015

As part of this, we might want to consider adding aliases that use dashes (or some other character) as well as underscores for each container. That way we could transition away from underscores in hostnames (which is technically invalid).

@dnephin
Copy link

dnephin commented Jan 19, 2016

This is now done in 1.6.0 (RC1 is out)

@dnephin dnephin closed this as completed Jan 19, 2016
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

2 participants