Search code examples
windowsdockerwindows-10google-cloud-sdklinux-containers

Cannot forward ports when running Linux container on Windows10 as a host


I'm new using Docker. I have been trying to deploy a Linux container (with Windows as a host) with a Google Cloud image inside using Docker. I'm able to do everything well, at the end the server is running perfectly, but when I want to check the server, using the localhost in the browser, I got a blank page with:

Blank page

This is the Dockerfile:

FROM google/cloud-sdk
ENV PATH /usr/lib/google-cloud-sdk/bin:$PATH
WORKDIR docker_folder
COPY local_folder/ .
RUN pwd
EXPOSE 8080
CMD ["java_dev_appserver.sh", "."]

This is the command I'm using to build my image (in the CMD):

docker build --tag serverdeploy .

This is the command I'm using to run my container

docker run -p 8080:8080 serverdeploy

This is the stack trace that I got when I run the server

where I know that I running the server

I did some research and looks like Docker had a problem with the ports when you use a Linux container in Windows (Not sure if it's already solved or not). I've already tried all the possible solutions that I found out there (even trying to replace 'localhost' by all the ip's that I get when I run ipconfig on the cmd) but I still get the same error.

And, as last hope, I need your help to understand what I'm doing wrong, or if I missing something


Solution

  • You are running your service bind to localhost - that means no remote connections are accepted (as well as binding to 127.0.0.1. And for your container the host is a remote connection.

    Change binding to 0.0.0.0 (which I guess is default) and enjoy.

    Btw sharing your java_dev_appserver.sh would be helpful for answering the question.