title: Access sibling service from docker container's service
body: <p>I run Node image based docker container (Docker quickstart terminal from Windows)</p>
  
  <pre><code>FROM node:7.8.0
  ENV NPM_CONFIG_LOGLEVEL warn
  
  VOLUME /tmp
  #copy server source /piu contains node server and /piu/client contains react+redux client
  ADD piu /piu
  ADD server_start.sh /
  
  #clean windows \r char to make the .sh file real executable
  RUN sed -i -e 's/\r$//' server_start.sh
  
  CMD ./server_start.sh
  
  EXPOSE 3000 3009
  </code></pre>
  
  <p>I start Node client (on port 3000) and Node (express based) server (on 3009 port). Client accesses REST server via AJAX call.</p>
  
  <pre><code>componentDidMount() {
      const that = this;
      console.log('SERVER_URL=' + SERVER_URL); //the output is localhost:3009
      axios
          .get(SERVER_URL + '/posts')
          .then(res =&gt; {
              that.setState({pageInfo: res.data});
          })
          .catch(err =&gt; {
              console.log(err)
          })
  }
  </code></pre>
  
  <p>It perfectly works from host (client accesses localhost:3009 and return results). And I can call :3009 and again have correct results.</p>
  
  <p>But when I build and run docker image it fails.</p>
  
  <pre><code>docker run -p 3000-3009:3000-3009 --add-host="mongodb:192.168.12.151" MyDockerImage
  </code></pre>
  
  <p><code>--add-host</code> is used to access mongo db running on host.</p>
  
  <p>Server port 3009 is exposed so I have a working trick to call </p>
  
  <pre><code>192.168.99.100:3009 //the docker IP and exposed port
  </code></pre>
  
  <p>instead of <code>localhost:3009</code> but would be nice to let client access server directly inside the container.</p>
  
  <p>How to specify localhost properly inside the docker container to access sibling service?</p>
  
  <p>UPDATE</p>
  
  <pre><code>#!/bin/bash
  
  # Start the first process (server)
  npm run start_docker --prefix piu &amp;
  status=$?
  if [ $status -ne 0 ]; then
    echo "Failed to start my_first_process: $status"
    exit $status
  fi
  
  # Start the second process (client)
  npm run start --prefix piu/client
  status=$?
  if [ $status -ne 0 ]; then
    echo "Failed to start my_second_process: $status"
    exit $status
  fi
  </code></pre>