0
votes

I've successfully uploaded a docker image of my app to GCR, made a GCE instance out of it, enabled http forwarding, and after SSH'ing into the GCE instance did a 'docker pull ' + 'docker run -d -p 8888:8888 ' but I am not able to access the app via the external IP + the port (8888). So then I tried SSHing into the GCE instance, and running 'docker exec -it curl -v http://localhost:8080/healthCheck' and I am able to access my app.

I've tried SSHing into my GCE instance and running 'docker exec -it curl -v http://localhost:8080/healthCheck' so I know that the app is running fine, it's just missing something that maps it to the external IP? I've also added the firewall rules (both 8888 and 8080) and I see they're mapped to the GCE instance.

Expected: Once I run 'docker run -d -p 8888:8888 ' from SSHing into the GCE instance, the app should be accessible by using the GCE instance's ExternalIP + port as well. Actual: Getting 'site can't be reached' in browser and an empty reply when using curl.

1
Does it work in Docker on your local system? This is usually caused by either (a) the process inside the container not listening on the special “all interfaces” 0.0.0.0 address, or (b) firewall setup (especially in a cloud environment may not be on the host per se).David Maze
It does work on my local system @DavidMazeP_equals_NP_2021
Are your firewall rules consistent with your desired outcome?Kolban
I've allowed all ports on my firewall rules, and they apply to all instances in my network... @KolbanP_equals_NP_2021
If one uses lsof or netstat on the GCE instance, does it show that port 8888 has an active listener?Kolban

1 Answers

2
votes

I think that your docker command is wrong. It should be 'docker run -d -p 8888:8080 ' because the -p flag state that the first number is going to be the host port and the second the container port[1]. Per you curl command being successful, your container is listening in the 8080 port.

You application should now work with 'http://[external IP]:8888/healthCheck' or https, don't know if you are using SSL/TLS.

[1] https://docs.docker.com/engine/reference/run/#expose-incoming-ports