Rent a Mac M4 Mini and Access It via SSH from Linux
I needed a Mac to run a Laravel test suite. On my ThinkPad T15g with Docker, the tests took so long I…
When working with Docker containers, one common challenge is how to connect from inside a container to other services - whether they're running directly on your host machine or in other containers. While Docker provides several networking solutions, there's one particularly elegant solution that's often overlooked: host.docker.internal.
host.docker.internal is a special DNS name that Docker Desktop provides to containers. It resolves to the internal IP address of the host machine, allowing containers to communicate with any service that's accessible through your host - whether that service is running natively on your machine or exposed by another container.
Think of it as a consistent, reliable way to say "hey container, when you need to talk to something through the host machine, use this address!"
Imagine these common scenarios:
Instead of dealing with IP addresses that might change or complex network configurations, host.docker.internal provides a stable, reliable way to reference anything that's accessible through your host machine - whether it's running natively or in another container.
Let's say you have a service running on your host machine on port 3000. From inside your container, you can access it like this:
$hostService = 'http://host.docker.internal:3000';
Development Only: While host.docker.internal is incredibly useful for development, it's not suitable for production environments. Your production containers shouldn't need to access the host machine.
Environment Variables: Consider using environment variables to make your connection strings configurable:
API_URL=http://host.docker.internal:3000
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com
Why does my application, when requesting host.docker.internal, have a 50% chance of accessing an IPv6 address? The operating environment is macOS 15, and Docker is Docker Desktop 4.37.1.