DEV Community

kohbis
kohbis

Posted on • Originally published at fushagoya.com

【Tips】Connect Host OS proccess by localhost from within Docker container

Tips for connecting Host OS process by localhost from within Docker container.

This is used when the container is running without using docker-compose for each process.

$ docker run -it --rm --add-host=localhost:$(ipconfig getifaddr en0) IMAGE
Enter fullscreen mode Exit fullscreen mode

Incidentally, if you don't use localhost and you are using Docker Desktop for Mac, you can connect using the DNS name host.docker.internal.

Discussion (0)