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

Impossible to link two containers simultaneously #182

Closed
Pitxyoki opened this issue May 27, 2015 · 4 comments
Closed

Impossible to link two containers simultaneously #182

Pitxyoki opened this issue May 27, 2015 · 4 comments
Assignees
Milestone

Comments

@Pitxyoki
Copy link

Hi,

When using docker, I'm able to run two containers from the same image, and link them both on a third container from another image.
For example, imagine the scenario where you are running some application and you want it to communicate with two Cassandra nodes:

$ docker  run --name cassandra_1 -d cassandra:2.1.5
$ docker  run --name cassandra_2 -d cassandra:2.1.5
$ docker  run --name base -d --link cassandra_1:cassandra_1 --link cassandra_2:cassandra_2 -it centos:centos6 top -b

From the "base" container, we can now access both Cassandra nodes:

$ docker exec base cat /etc/hosts
172.17.0.29 9a20d5424ad4
127.0.0.1   localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.27 cassandra_1 7aa7f3a6f69b
172.17.0.28 cassandra_2 a2c2583275e4

See the details of the base image on the gist (inspect_native_2 file): https://gist.github.com/Pitxyoki/adba7fe14fc39e2d1514#file-inspect_native_2

$ docker  rm -f base cassandra_1 cassandra_2

However, I'm not being able to achieve the same with docker-maven-plugin. See the project on the gist: https://gist.github.com/Pitxyoki/adba7fe14fc39e2d1514#file-test_project-patch
Apply on an empty dir with git apply test_project.patch and execute the following:

test_project$ mvn clean install
test_project$ cd twocassandras
twocassandras$ mvn docker:start
twocassandras$ docker exec base cat /etc/hosts
172.17.0.32 2d77904ac42d
127.0.0.1   localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.31 cassandra_2 cassandra_2
172.17.0.31 cassandra_1 cassandra_2 cassandra_2

Notice that only one of the IPs is there and the hostnames seem to be mangled.
This makes it impossible to reach both Cassandra nodes.

More details on the gist: inspect_plugin_2: https://gist.github.com/Pitxyoki/adba7fe14fc39e2d1514#file-inspect_plugin_2

$ docker  rm -f base cassandra_1 cassandra_2

Reducing this to a simpler case might help (?):

$ docker  run --name cassandra_1 -d cassandra:2.1.5
$ docker  run --name base -d --link cassandra_1:cassandra_1 -it centos:centos6  top -b
$ docker exec base cat /etc/hosts
172.17.0.34 0c672f295050
127.0.0.1   localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.33 cassandra_1 fe96d0a3c247

See inspect_native_1.txt: https://gist.github.com/Pitxyoki/adba7fe14fc39e2d1514#file-inspect_native_1

$ docker  rm -f base cassandra_1 cassandra_2
test_project$ mvn clean install
test_project$ cd onecassandra
onecassandra$ mvn docker:start
onecassandra$ docker  exec base cat /etc/hosts
172.17.0.36 7baabd019e91
127.0.0.1   localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.35 cassandra_1 cassandra_1

See inspect_plugin_1: https://gist.github.com/Pitxyoki/adba7fe14fc39e2d1514#file-inspect_plugin_1

onecassandra$ mvn clean

This seems like a current limitation/bug of the plugin but please tell me if I'm doing something wrong.

Thank you.

@rhuss
Copy link
Collaborator

rhuss commented May 27, 2015

thanks for the degtailed report, I will have a look ASAP (but probably not before next week because of work load). It smells indeed like a bug.

@knoppiks
Copy link

The bug still appears in v0.13.2
Did you have time to look into this yet? @rhuss
I have described the same bug in #184, if I'm not mistaken.

@jgangemi
Copy link
Collaborator

i just took a look at this and they appear to be the same.

based on what i see, this has something to do w/ the plugin using the image name to match against instead of relying on the specified alias (similar to #87, although using labels won't fix this problem).

i should have some time later tonight to dig deeper.

@jgangemi jgangemi added the bug label Jul 30, 2015
@jgangemi jgangemi added this to the 0.13.3 milestone Jul 30, 2015
@jgangemi jgangemi self-assigned this Jul 30, 2015
@jgangemi
Copy link
Collaborator

i have a fix for this. part of the 'problem' is the plugin is too flexible and allows an alias to be optional and lets you specify links and volumes using an image name or an alias. if you specified an alias, the underlying code tracked that against an image name, so if you had more then one container running under the same image, the entries would get overwritten in the map.

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

4 participants