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.
Symptoms
curl localhost:8080fails, but the service works inside the container.- You cannot ping or connect to the container's IP address.
- No
docker0interface 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
List the running containers and their published ports.
docker psOutput The PORTS column shows pairs such as
0.0.0.0:8080->80/tcp. No pair means the port is not published.Show the published ports of one container.
docker port my-containerTest 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:80See which process on the Mac listens on the port.
lsof -nP -iTCP:8080 -sTCP:LISTEN
How to fix it
Start the container with a published port. The first number is the port on the Mac.
docker run -d -p 8080:80 nginxConnect from the Mac with localhost and the Mac port.
curl http://localhost:8080Make the service in the container listen on 0.0.0.0, not 127.0.0.1. See its own documentation for the setting.
If the Mac port is in use, choose another Mac port. See Port already in use on a Mac.
With OrbStack, you can also use the container's IP address or its
container-name.orb.localname.
With Kilobat
Kilobat's checks run on the Mac. Use
--context containerwhen 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
- Docker Docs: Explore networking how-tos on Docker Desktop
- Docker Docs: Networking on Docker Desktop
- OrbStack Docs: Container networking
- lsof(8), man page installed with macOS 27.2
Sources checked on 29 October 2026. Man pages are the ones installed with macOS; open one with man <name> in Terminal.