There are couple of issues that I have encountered while working with Docker.
- Host (Windows 10) is not able to access any resources hosted by containers.
- Containers themselves are also not seeing each other.
My config:
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
Dockerfile for chrome (all it does - starts Chrome with debugging, enabled on port 9223):
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" >> /etc/apt/sources.list.d/google.list'
RUN apt-get update && 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"]
docker-entrypoint.sh
#!/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/
Dockerfile for second app (is used just for docker internal network testing)
FROM mcr.microsoft.com/dotnet/core/runtime:2.2
# run app
CMD ["/bin/bash"]
So, now, to elaborate on point 1:
I can launch chrome container by running: docker-compose up --build chrome.
On host system I then try to open a browser either localhost:9223 or http://172.17.0.2:9223/ and in both cases I get "page could not be reached error". P.s. I got IP from docker inspect command.
On the other hand, if I try to go into running container docker exec -it chrome_container bash and execute command curl localhost:9223 then it shows a SUCCESS result.
At this point if I try using other address like curl chrome:9223 or curl http://chrome:9223 orcurl chrome_container:9223 or curl http://chrome_container:9223 then they also FAIL. According to documentation - all containers within internal network shall be accessible by the service host name. This is simply false in my scenario.
I also tried starting the image without relying on docker compose like this docker run -p 9223:9223 -it --rm all_chrome but the result is the same. The resource is not available from within host system.
Now, to elaborate on issue 2.
When I run both applications like this docker-compose up. And log-into second app by docker exec -it live_container bash. And then try to access first container using above mentioned URLS - all of them fail (curl localhost:9223 or curl 0.0.0.0:9223 or curl chrome:9223 or curl http://chrome:9223 orcurl chrome_container:9223 or curl http://chrome_container:9223).
I tried restarting Docker a couple of times and tried different ports. How can I figure out these things?
- How to access resource at 9223 port at Host system? 
- Why isn't the second service able to see the first service using the host name, as documented here? 
I am using Docker on Windows 10.
EDIT: More details.
- When accessing by localhost - following error is showed:
- When accessing by IP- following error is showed:
So it seems like something is happening when accessing by localhost on a Host system (win 10).





 
     
    