Docker: access host database from container on Mac

With things like homebrew you kind of forget that you’re not on Linux, and some things might actually work differently. Trying to connect to a host database server from the container using didn’t work out.

After few hours, figuring out that everything’s setup right, you’re not going crazy, you stumble upon this note:

The host has a changing IP address (or none if you have no network access). From 18.03 onwards our recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host. This is for development purpose and will not work in a production environment outside of Docker Desktop for Mac.

The gateway is also reachable as gateway.docker.internal.


And everything works like charm:

[root@e70e59cdb3c3 /]# ping host.docker.internal
PING host.docker.internal ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=37 time=0.951 ms

[root@e70e59cdb3c3 /]# mysql -u root -h host.docker.internal -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 350

Docker partners Microsoft

Today, we announced an exciting set of joint initiatives with Microsoft, including:

  • Extending Docker to Windows with Docker Engine for Windows Server
  • Microsoft’s support of Docker’s open orchestration APIs
  • Integration of Docker Hub with Microsoft Azure, and
  • Collaboration on the multi-Docker container model, including support for applications consisting of both Linux and Windows Docker containers

I’d like to provide some context for this announcement, and why we are so excited.
When Docker was launched as an open source project 18 months ago, we had a simple goal:
“To build the ‘button’ that enables any application to be built and deployed on any server, anywhere.”

Great news for Docker. The more the merrier