Docker Community Forums

Share and learn in the Docker community.

Accessing Machines on Local Network From a Container on Mac Desktop

Hi

I have Docker for Mac running on two different Mac’s on my local network. These machines can access each other through their local ip addresses. I am running the latest release of Docker Desktop on Catalina.

I have seen that there is a way for a container to get access and connect to the hosts ip address through host.docker.internal as detailed here: https://docs.docker.com/docker-for-mac/networking/

I not only want to get access and connect from a container to the hosts IP address but also any other machine on my local network and in particular another Mac running Docker.

I have looked at many of the network options ( using docker swarm, host network, macvlan, overlay) but all of them do not seem to allow this on the Mac version of Docker.

Is there any way for a container running on one of the Mac’s to connect to another Mac on the same local network ?

In the article referenced above it also mentions “You can also reach the gateway using `gateway.docker.internal.” Can I use this to achieve what I want ?

Hoping someone can help and advise.

Cheers

Don’t you try to port forward a port from your Docker on Machine 1 and port forward the same port from Machine 1 to Machine 2 ?

If you want to access a shared folder from Machine 1 to Machine 2, you should try to mount a volume on your Docker Container to the shared Folder on Machine 1 and it should be accessible on Machine 2.
docker run -v <shared folder path on Machine 1>:<path on Docker Container> -d <container ID>

This post was flagged by the community and is temporarily hidden.