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

cannot access localhost from Docker container [closed]

$
0
0

I followed this tutorial step by step : https://www.youtube.com/watch?v=NZGu-9KQVsE

  • I created a Dockerfile :

FROM ubuntu:jammy

RUN : \&& apt-get update \&& DEBIAN_FRONTEND=noninteractive apt-get install -y \        curl \&& apt-get clean \&& rm -rf /var/lib/apt/lists/*
  • I built the docker image :
docker build -t mycurl .
  • I ran the image using
docker run --add-host host.docker.internal:host-gateway --rm -ti mycurl bash
  • I started a local server using
python3 -m http.serverServing HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...
  • But when I try to access it from my container, i get this timeout :
root@da4d8b1f4ae4:/# curl host.docker.internal:8000curl: (28) Failed to connect to host.docker.internal port 8000 after 133451 ms: Connection timed out

My /etc/hosts is :

root@da4d8b1f4ae4:/# cat /etc/hosts127.0.0.1   localhost::1 localhost ip6-localhost ip6-loopbackfe00::0 ip6-localnetff00::0 ip6-mcastprefixff02::1 ip6-allnodesff02::2 ip6-allrouters172.17.0.1  host.docker.internal172.17.0.2  da4d8b1f4ae4

Any idea why ? I am on Ubuntu 22.04.4 LTS


Viewing all articles
Browse latest Browse all 6025

Trending Articles



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