Getting MacBook IP address from Multipass + Docker

Hi.

I’ve just come across Multipass and it looks perfect for what I want to do in terms of setting up a development environment. I’ve tested everything that I already have and it is working perfectly, BUT with one caveat - is there a way to get the host IP address from either within the docker containers running in Multipass, or failing that from within the Multipass VM itself?

The scenario is, I have a number of web server and FPM containers running in the Multipass VM and these work fine, everything seems okay at the moment. What I want to do though is have those containers connect to a MySQL server running on the host (in this case my MacBook Pro). So, visually - this is what I need…

Docker Container -> Guest (MP VM) -> Host [MacBook] (this is the IP address I want)

Failing that, is there any way that I can route a request from the container through the MP VM to the Mac for port 3306?

I can build the DB as a container yes, and that would probably work fine but I want to maintain the DB on my MacBook so I can use it any time sometimes without bothering to spin up the VMs etc

In short, I guess it boils down to what IP address do I need to use so that the Guest machine (and / or Docker containers running therein) can connect to the Host machine. The reverse works fine of course and I can connect to Portainer fine, and the web servers running inside the docker containers etc - I just need communication between the Guest and the Host to now work fine

Is this something I need to change in the set up of the MP VM?

Thanks in advance for any help :slight_smile:

Gah - isn’t it always the way that as soon as you ask a question you manage to find the answer!

In case anyone else is wondering, this is what I did…

multipass exec docker -- ip route                        
default via 192.168.205.1 dev enp0s1 proto dhcp src 192.168.205.3 metric 100 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.205.0/24 dev enp0s1 proto kernel scope link src 192.168.205.3 metric 100 
192.168.205.1 dev enp0s1 proto dhcp scope link src 192.168.205.3 metric 100 

That gave me the 192.168.205.1 IP address which I checked with a curl to that IP + 3306 as a port and received a “http not allowed” response, so knew that was probably my local DB server

Updated configs in the applications and now works fine

Just in case anyone else needed that information :slight_smile: