How to send data from within a container to the host on Mac?

Hi,

If I want to send data from within a container to the host, so that the process running on that host could receive that data from its localhost UDP port, what should I do?
It is said that on Linux we can do that using host network, but on Mac host network is not available.

Thanks!

From command line with docker cp (https://docs.docker.com/engine/reference/commandline/cp/)

docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

You cannot do this on a Mac because Docker does not run natively on a Mac; it actually runs in a hidden VM using Mac hyperkit. So the host network would be established with the VM, not with macOS. The reason this works on Linux is because Docker runs natively on the Linux kernel.

I would solve this by running whatever is on your Mac localhost in it’s own Docker container and then start the two containers on their own network, Then they can reach each other by DNS names.

~jr

this might help: