title: Docker containers are not able to see each other in docker compose, nor is host
body: <p>There are couple of issues that I have encountered while working with Docker.</p>
  
  <ol>
  <li>Host (Windows 10) is not able to access any resources hosted by containers.</li>
  <li>Containers themselves are also not seeing each other.</li>
  </ol>
  
  <p>My config:</p>
  
  <pre><code>version: '3.7'
  services:
    chrome:
      build: ./chrome
      container_name: chrome_container
      ports:
        - "9223:9223"
  
    dotnetapp:
      depends_on:
         - chrome
      build: ./dotnetapp
      container_name: live_container
      environment:
        - ASPNETCORE_ENVIRONMENT=Production
      stdin_open: true
      tty: true
  </code></pre>
  
  <p><code>Dockerfile</code> for chrome (all it does - starts Chrome with debugging, enabled on port 9223):</p>
  
  <pre><code>FROM debian:buster-slim
  
  # preparation
  RUN apt-get update; apt-get clean
  RUN apt-get install -y wget
  RUN apt-get install -y gnupg2
  
  # installing xvfb
  RUN apt-get install -y xvfb
  
  # installing Chrome
  RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
  RUN sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" &gt;&gt; /etc/apt/sources.list.d/google.list'
  RUN apt-get update &amp;&amp; apt-get install -y google-chrome-beta
  
  EXPOSE 9223
  
  COPY ./docker-entrypoint.sh /usr/local/bin/
  RUN ln -s usr/local/bin/docker-entrypoint.sh / # backwards compat
  ENTRYPOINT ["docker-entrypoint.sh"]
  CMD ["test"]
  </code></pre>
  
  <p><code>docker-entrypoint.sh</code></p>
  
  <pre><code>#!/bin/bash
  set -e
  
  if [ "$1" = 'test' ]; then
      rm -f /tmp/.X99-lock
  fi
  
  xvfb-run -e /dev/stdout --server-args='-screen 0, 2560x1440x16' google-chrome --window-size=2560,1440 --no-sandbox --remote-debugging-port=9223 --user-data-dir=remote-profile https://www.google.com/
  </code></pre>
  
  <p><code>Dockerfile</code> for second app (is used just for docker internal network testing)</p>
  
  <pre><code>FROM mcr.microsoft.com/dotnet/core/runtime:2.2
  
  # run app
  CMD ["/bin/bash"]
  </code></pre>
  
  <p><strong>So, now, to elaborate on point 1:</strong></p>
  
  <p>I can launch chrome container by running: <code>docker-compose up --build chrome</code>.</p>
  
  <p>On host system I then try to open a browser either <code>localhost:9223</code> or <code>http://172.17.0.2:9223/</code> and in both cases I get "page could not be reached error". P.s. I got IP from <code>docker inspect</code> command.</p>
  
  <p><a href="https://i.stack.imgur.com/oKyMa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oKyMa.png" alt="enter image description here"></a></p>
  
  <p>On the other hand, if I try to go into running container <code>docker exec -it chrome_container bash</code> and execute command <code>curl localhost:9223</code> then it shows a SUCCESS result.</p>
  
  <p><a href="https://i.stack.imgur.com/8CtZb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8CtZb.png" alt="enter image description here"></a></p>
  
  <p>At this point if I try using other address like <code>curl chrome:9223</code> or <code>curl http://chrome:9223</code> or<code>curl chrome_container:9223</code> or <code>curl http://chrome_container:9223</code> then they also FAIL. According to documentation - all containers within internal network shall be <a href="https://docs.docker.com/compose/networking/" rel="nofollow noreferrer">accessible by the service host name</a>. This is simply false in my scenario.</p>
  
  <p>I also tried starting the image without relying on <code>docker compose</code> like this <code>docker run -p 9223:9223 -it --rm all_chrome</code> but the result is the same. The resource is not available from within host system.</p>
  
  <p><strong>Now, to elaborate on issue 2.</strong></p>
  
  <p>When I run both applications like this <code>docker-compose up</code>. And log-into second app by <code>docker exec -it live_container bash</code>. And then try to access first container using above mentioned URLS - all of them fail (<code>curl localhost:9223</code> or <code>curl 0.0.0.0:9223</code> or <code>curl chrome:9223</code> or <code>curl http://chrome:9223</code> or<code>curl chrome_container:9223</code> or <code>curl http://chrome_container:9223</code>).</p>
  
  <p>I tried restarting Docker a couple of times and tried different ports. How can I figure out these things?</p>
  
  <ol>
  <li><p>How to access resource at 9223 port at Host system?</p></li>
  <li><p>Why isn't the second service able to see the first service using the host name, as documented <a href="https://docs.docker.com/compose/networking/" rel="nofollow noreferrer">here</a>?</p></li>
  </ol>
  
  <p>I am using Docker on Windows 10.</p>
  
  <p><a href="https://i.stack.imgur.com/sy9Rg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sy9Rg.png" alt="enter image description here"></a></p>
  
  <p><strong>EDIT:</strong> More details.</p>
  
  <ul>
  <li>When accessing by localhost - following error is showed:</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/cpxwE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cpxwE.png" alt="enter image description here"></a></p>
  
  <ul>
  <li>When accessing by IP- following error is showed:</li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/kSEcs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kSEcs.png" alt="enter image description here"></a></p>
  
  <p>So it seems like something is happening when accessing by localhost on a Host system (win 10).</p>