0

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

grapes
  • 8,185
  • 1
  • 19
  • 31

1 Answers1

0

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.

grapes
  • 8,185
  • 1
  • 19
  • 31
  • Thank you for your answer, but I have just written docker run -p 0.0.0.0:8080:8080 serverdeploy and I get the same error. Is the correct place to write the binding? And regarding the java_dev_appserver.sh is the Google Cloud SDK – Adrian Agramon Feb 01 '19 at 11:12
  • Its not what I meant. When you bind `-p 0.0.0.0:blahblah` you bind docker to host's interface. While I think your problem is that your service is bind to `localhost` inside container – grapes Feb 01 '19 at 11:20
  • So you mean my server should run on 0.0.0.0:8080 instead of localhost:8080? If not, can you tell me what should I change? I don't know if I'm misunderstanding something as I'm new at Docker. Thank you for your help – Adrian Agramon Feb 01 '19 at 11:36
  • I manage to make it work! I the CMD line of my Dockerfile to this: `CMD java_dev_appserver.sh -a 0.0.0.0 -p 8080 .` – Adrian Agramon Feb 01 '19 at 15:44
  • Congrats! That's what I was talking about when telling about sharing your shell file – grapes Feb 01 '19 at 15:48