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.server
Serving HTTP on port 8000 ( ...
  • But when I try to access it from my container, i get this timeout :
root@da4d8b1f4ae4:/# curl host.docker.internal:8000
curl: (28) Failed to connect to host.docker.internal port 8000 after 133451 ms: Connection timed out

My /etc/hosts is :

root@da4d8b1f4ae4:/# cat /etc/hosts   localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters  host.docker.internal  da4d8b1f4ae4

Any idea why ? I am on Ubuntu 22.04.4 LTS

1 Answer 1


I solved my problem by running this :

sudo ufw allow 8000

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .