title: Spring & Docker: RMI Hostname resolved to 0.0.0.0 and not to its expected IP address
body: <p>I am currently working on a project that associates Docker and Spring programs with an RMI service, and I can't find a way to resolve my problem.</p>
  
  <p>I'm trying to deploy two Spring programs into two distinct containers, through a <code>docker-compose.yml</code> file. The first one exposes an RMI interface at address <code>0.0.0.0</code> (everything), and on a specific port (which is EXPOSEd as well in the Docker file). And the second one is just an RMI client using the remote interface.</p>
  
  <p>To access the container that exposes the RMI service from the other, I gave it an alias through the <code>links</code> parameter in the Compose file, like this :</p>
  
  <pre><code>services:
    rmi-service:
      ...
  
    rmi-client:
      ...
      links:
        - rmi-service:rmihost
  </code></pre>
  
  <p>When I start my containers with <code>docker-compose up -d</code>, if I execute the command <code>ping rmihost</code> from the second container, it works well. But when I try to start my Spring RMI client, I get the following error:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'my.rmi.client' defined in class path resource [META-INF/rmi-client-spring.xml]: Invocation of init method failed; nested exception is
  org.springframework.remoting.RemoteConnectFailureException: Could not connect to remote service [rmi://rmihost:11199/businessService]; nested exception is
  java.rmi.ConnectException: Connection refused to host: 0.0.0.0
  </code></pre>
  
  <p>I can't figure out why it doesn't translate the hostname into the correct IP address, while I'm able to <code>ping</code> it. I tried adding the <code>rmihost</code> in the <code>/etc/hosts</code> file, but it doesn't change anything, it always gives the same error.</p>
  
  <p>Any help or suggestion on this problem will be greatly appreciated! Thanks in advance!</p>
  
  <p><strong>EDIT</strong> Here is my <code>docker-compose.yml</code> file :</p>
  
  <pre><code>version: '2.1'
  
  services:
    rmi-service:
      restart: always
      tty: true
      build: ./rmi-service/
      image: rmi-service
      container_name: rmi-service
      expose:
        - "11199"
  
    rmi-client:
      restart: always
      tty: true
      build: ./rmi-client/
      image: rmi-client
      container_name: rmi-client
      depends_on:
        - rmi-service
      links:
        - rmi-service:rmihost
  </code></pre>