DEV Community


Posted on • Originally published at

【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.

Top comments (0)