-
Notifications
You must be signed in to change notification settings - Fork 642
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
container ip #198
Comments
at the moment, no. but is something that could be added. you would need to define what property you want to use for the container's address (similar to how the random port mapping works) |
At the moment Adding another fixed variable shouldn't be a problem (however I guess we have to issue an extrac REST call to get to this information). However, I wonder what your use case is ? Isn't it, that from the outside the docker host IP should be sufficient for accessing your container ? Why and where do you need the internal IP ? (just curious) |
Thank you for the answer. |
I'm confused ;-) You start a Jenkins Job which runs |
Good question : -) The jenkins and the job using the docker-maven-plugin run in another container. The docker-maven-plugin ("container J") start and stop the docker containers contacting the IP of "Container N" on port 4232 (property "dockerHost" in the docker-maven-plugin, which I can override with a maven environment variable), which correspond to the standard Docker Remote API, as configured in nginx. |
Ah, ok. You are doing some proxying in between (so you access container N as a proxy for the Docker host which is only accessible via Unix socket. BTW, the docker maven plugin supports now also access to Unix sockets directly since 0.12.0) For me it looks a little bit like a quite complex setup ;-) (which is probably not so common in general) so I wonder whether its worth to introduce this extra step for querying the docker daemon about more information of the container. Maybe we could do this an option like 'exposeContainerInfo'. However then there is still the problem how this properties should be exposed since there can be multiple containers configured. So probably with the container name as prefix (like Maybe you could share the docker host's IP via an environment variable ? I think this could work:
The only thing which could possibly could go wrong here is that |
Yes I know, my currently Jenkins installation it's a little bit exotic, unfortunately I can't change it... :-( |
- update dynamic ports in the run service - cleaned up compiler warnings - allow 'HostIp' to be bound as maven property and exported - introduced 'PortMapping.Writer' to handle property file writing Signed-off-by: Jae Gangemi <jgangemi@gmail.com>
Any updates on that? |
actually... it looks like the day job need some form of this functionality b/c we are running docker in docker and starting a mysql container w/ in the docker container and have no way to route to it. @rhuss - can't we just have the user specify a distinct property name they want to read the ip into on a per container basis? we could add a <exposedContainerInfo>
<ipAddress>container1.ip.address</ipAddress>
...
</exposedContainerInfo> that would give an easy way to expose additional container details back to the build in the future. |
+1 I have HBase and Zookeeper running in docker and integration test running outside docker. I could get the random port for consul DNS but it looks like defining sun.net.spi.nameservice.nameservers can only contain an ip address, not a custom port (standard DNS port is 53 which is typically not free). Things work as expected if I give (hard code) -Dsun.net.spi.nameservice.nameservers=172.17.0.2 on maven-failsafe-plugin argLine. I just can't find a way to get that docker internal ip address from anywhere.
|
I see that there are several use cases for exposing container information into Maven properties. My suggestion is to use a Since we already have the inspect REST call implemented this shouldn't be a big deal. I would start with the internal IP address and extend on this according to requirements coming in. (So I wouldn't expose all information available right now) |
+1 We are also running docker in docker (Bamboo) and retrieving the container ip is a must for the integration tests. Another option might be to start the container (integration-test) with the option |
The changelog says "Allow the container's host ip to be bound to a maven property and exported" on version 0.13.3, but I couldn't figure out how to do it, couldn't find it in the docs or by searching the repo. |
see the the |
I have a very similar use case to @lofbele1, except I'm running three Docker containers with MongoDB to form a replica set. I'm starting a fourth container that links to the first three and connects to the first MongoDB instance (the primary) to initiate the replica set and add the addresses of the other 2 MongoDB containers, and this container then exits. I can get everything set up, but when my integration tests, my tests need the address of each MongoDB container in order to connect; it'd be awesome if my build could set system properties using generated Maven properties. I really just need the IP addresses of each container, and the Maven property could be named based upon my assigned alias for each container. For example, given containers with names |
@rhuss, your proposal looks great, and is exactly what I need to get around my current issue with trying to start up a MongoDB replica set for use by integration tests. |
@rhuss, I'm using this the latest commit in my build, and I'm trying to use the
where
Here's the stack trace:
Are the containers not being created and started in the same order they are defined in the file? I even tried adding links to the first 3 containers to try to force the fourth container to be created and started after the others. Any clue why the container IP address properties are not being resolved in the image configuration creation? |
I'm in the road at the moment, but containers are created in parallel when Randall Hauch notifications@github.com schrieb am Mi., 27. Apr. 2016
|
This also doesn't seem to work for me. I will try to come up with a simple example in order to debug it. |
https://gist.github.com/andredasilvapinto/e09d52a0940f2ecf29c7dbc9db401dd4
|
it works well when using it in another plugin like how it's done here: the problem is with using it inside other containers in the same plugin/execution |
OK, so after a few hours of debugging, things need to happen:
|
Support for docker command line option --build-arg
Inside pom.xml:
with the property "docker.host.address" I can get the IP of the host running docker daemon.
with the property "host.port" I can get the published port assigned to the container started with the plugin.
Is there a property to get the IP assigned by docker to the container started by the plugin ?
The text was updated successfully, but these errors were encountered: