![]() When running Docker natively on Linux, you can access host services using the IP address of the docker0 interface. ![]() The alias will reset on every reboot so create a start-up script if necessary. To test you can run something like curl -X GET 123.123.123.123:3000 inside the container. Then just point your docker container to this IP and you can access the host machine! If it's listening on localhost 127.0.0.1 it will not accept the connection. Then make sure that you server is listening to the IP mentioned above or 0.0.0.0. You can bind whichever IP you want, just make sure you're not using it to anything else. To access host machine from the docker container you must attach an IP alias to your network interface. Linux support pending MacOS with earlier versions of Docker Docker for Mac v 17.12 to v 18.02 ![]() To enable this in Docker Compose on Linux, add the following lines to the container definition: extra_hosts:įor macOS and Windows Docker v 18.03 and above (since March 21st 2018) Use your internal IP address or connect to the special DNS name which will resolve to the internal IP address used by the host. (See below for Docker Compose configuration.) On Linux, add -add-host=:host-gateway to your Docker command to enable this feature. For all platforms Docker v 20.10 and above (since December 14th 2020) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
February 2023
Categories |