I am using Docker for Mac. I am running a nodejs based microservice in a Docker container. I want to test node microservice through the browser. How to get IP address of running docker container?
If you want to view the IP address from within the running container, /etc/hosts file is a great place to look at. Now, to uniquely identify the entry within the hosts file, it is a good practise to run the container with the -h option. Sample commands are given below:
运行设置为 -h的容器:
docker run -td -h guju <image name>
Log in to the running container and view the /etc/hosts file. It will show an entry like this: