title: ERR_NAME_NOT_RESOLVED using Docker network to communicate between a backend container and a React container
body: <p>I have a backend up (NodeJS) which is the listening on some port (2345 in this example). 
  The client application is a React app. Both are leveraging <code>socket.io</code> in order to communicate between themselves. Both are containerized.
  I then run them both on the same network, using the "network" flag:</p>
  
  <p><code>docker run -it --network=test1 --name serverapp server-app
  docker run -it --network=test1 client-app</code></p>
  
  <p>In the client, I have this code (in the server the code is pretty standard, almost copy-paste from socket.io page):</p>
  
  <pre><code>const socket = io.connect('http://serverapp:2345');
  socket.emit('getData');
    socket.on('data', function(data) {
        console.log('got data: ${data}');
    })
  </code></pre>
  
  <p>What I suspect is that the problem has to do with having the client (React) app served by the <code>http-server</code> package, and then in the browser context, the hostname is not understood and therefore cannot be resolved. When I go into the browser console, I then see the following error: <strong>GET <a href="http://tbserver:2345/socket.io/?EIO=3&amp;transport=polling&amp;t=MzyGQLT" rel="nofollow noreferrer">http://tbserver:2345/socket.io/?EIO=3&amp;transport=polling&amp;t=MzyGQLT</a> net::ERR_NAME_NOT_RESOLVED</strong></p>
  
  <p>Now if I switch (in the client-app) the hostname <code>serverapp</code> to localhost (which the browser understands but is not recommended to use in docker as it is interpreted differently), when trying to connect to the server socket, I get the error: <strong>GET <a href="http://localhost:2345/socket.io/?EIO=3&amp;transport=polling&amp;t=MzyFyAe" rel="nofollow noreferrer">http://localhost:2345/socket.io/?EIO=3&amp;transport=polling&amp;t=MzyFyAe</a> net::ERR_CONNECTION_REFUSED</strong>.</p>
  
  <p>Another piece of information is that we currently <strong>build the React app</strong> (using <code>npm run build</code>), <strong>and then</strong> we build and run the Docker container using the following Dockerfile:</p>
  
  <pre><code>FROM mhart/alpine-node
  RUN npm install -g http-server
  WORKDIR /app
  COPY /app/build/. /app/.
  EXPOSE 2974 2326 1337 2324 7000 8769 8000 2345
  CMD ["http-server", "-p", "8000"]`
  </code></pre>
  
  <p>(So, no build of the React app takes place while building the container; we rather rely on a prebuilt once)</p>
  
  <p>Not sure what I am missing here and if it has to do with the <code>http-server</code> or not, but prior to that I managed to get a fully working <code>socket.io</code> connection between 2 NodeJS applications using the same Docker network, so it shouldn't be a code issue.</p>