Developers

Cannot reach a Docker container from the Mac

Docker on a Mac runs containers in a Linux virtual machine. To reach a container from macOS, you usually publish a port to localhost.

Applies to: Docker Desktop and OrbStack on current macOS versions.Checked: 29 October 2026

Symptoms

  • curl localhost:8080 fails, but the service works inside the container.
  • You cannot ping or connect to the container's IP address.
  • No docker0 interface shows on the Mac.
  • The service works on Linux but not on the Mac.

Likely causes

  • The port is not published. Without -p, Docker Desktop does not forward the port to the Mac.
  • Container IPs on Docker Desktop. Docker's documentation for Docker Desktop says that its bridge network is not reachable from the host.
  • The service listens on 127.0.0.1 in the container. Then only the container itself can connect to it.
  • A wrong port pair. In -p 8080:80, 8080 is the Mac port and 80 is the container port.

How to check

  1. List the running containers and their published ports.

    docker ps

    Output The PORTS column shows pairs such as 0.0.0.0:8080->80/tcp. No pair means the port is not published.

  2. Show the published ports of one container.

    docker port my-container
  3. Test the service from inside the container, if the image includes wget. A reply means that the service works.

    docker exec my-container wget -qO- http://localhost:80
  4. See which process on the Mac listens on the port.

    lsof -nP -iTCP:8080 -sTCP:LISTEN

How to fix it

  1. Start the container with a published port. The first number is the port on the Mac.

    docker run -d -p 8080:80 nginx
  2. Connect from the Mac with localhost and the Mac port.

    curl http://localhost:8080
  3. Make the service in the container listen on 0.0.0.0, not 127.0.0.1. See its own documentation for the setting.

  4. If the Mac port is in use, choose another Mac port. See Port already in use on a Mac.

  5. With OrbStack, you can also use the container's IP address or its container-name.orb.local name.

With Kilobat

  1. Kilobat's checks run on the Mac. Use --context container when the failing code runs in a container. The report then ends with a command to run there.

    kilobat why http://localhost:8080 --context container

Questions

Why can I not ping a container on Docker Desktop?

Docker's documentation says that Docker Desktop cannot route traffic to Linux containers from the Mac. Publish a port instead.

Does OrbStack work differently?

Yes. OrbStack's documentation says that you can connect to containers by IP address and by .orb.local names from the Mac.

Sources

Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with man <name> in Terminal.