Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6052

Reaching localhost from within docker not working [closed]

$
0
0

I am running a docker image on ubuntu server 22.04.2I have two different "web apps" one is a system services exposed on localhost:8008 and another running on docker, but exposed on 0.0.0.0:80. I am suppose to reach the docker web app from the "oustide" and I am, but the system service app is only suppose to be reached from localhost and from inside the docker app.

When I test this out on MacOS and Windows with the same compose I am able to reach both localhost:8008 and 0.0.0.0:80 by the address host.docker.internal:3000 or : 8008, but on Ubuntu inside the docker I am not able to reach host.docker.internal:8008 I can only reach host.docker.internal:80.

docker-compose.yaml

  some-service:    image: some/image    container_name: some-container    ports:      - "80:80"    volumes:      - volume:/var/lib/volume    env_file:      - .env    restart: unless-stopped    privileged: true    extra_hosts:      - host.docker.internal:host-gateway

My initial thoughts was some sort of firewall, but that is disabled.

Curl output:

Trying to reach port 80 from inside the docker application

/ # curl -v host.docker.internal:80* Host host.docker.internal:80 was resolved.* IPv6: (none)* IPv4: 172.17.0.1*   Trying 172.17.0.1:80...* Connected to host.docker.internal (172.17.0.1) port 80> GET / HTTP/1.1> Host: host.docker.internal> User-Agent: curl/8.5.0> Accept: */*>< HTTP/1.1 200 OK< Server: openresty/1.25.3.1< Date: Thu, 20 Jun 2024 10:41:14 GMT< Content-Type: text/html< Content-Length: 643< Last-Modified: Fri, 01 Mar 2024 10:56:28 GMT< Connection: keep-alive< ETag: "65e1b45c-283"< Accept-Ranges: bytes<* Connection #0 to host host.docker.internal left intact<!doctype html>

Switching to port 8008 from inside the docker:

/ # curl -v host.docker.internal:8008* Host host.docker.internal:8008 was resolved.* IPv6: (none)* IPv4: 172.17.0.1*   Trying 172.17.0.1:8008...* Connected to host.docker.internal (172.17.0.1) port 8008> GET / HTTP/1.1> Host: host.docker.internal:8008> User-Agent: curl/8.5.0> Accept: */*>* Empty reply from server* Closing connectioncurl: (52) Empty reply from server

When curling from host to the system service running on port 8008:

root@updater3:/home/iqu# curl -v localhost:8008*   Trying 127.0.0.1:8008...* Connected to localhost (127.0.0.1) port 8008 (#0)> GET / HTTP/1.1> Host: localhost:8008> User-Agent: curl/7.81.0> Accept: */*>* Mark bundle as not supporting multiuse< HTTP/1.1 200 OK< Server: Werkzeug/3.0.1 Python/3.10.12< Date: Thu, 20 Jun 2024 10:48:32 GMT< Content-Type: text/html; charset=utf-8< Content-Length: 27< Connection: close<* Closing connection 0Updater service is running!

This is what the response should be from 8008: Updater service is running!.

I greatly appreciate any help to solve this issue.


Viewing all articles
Browse latest Browse all 6052

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>