In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to get the ip address of the docker container (container). The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
1. After entering into the container,
Cat / etc/hosts
The container IP that displays itself and (- link) the soft connection
two。 Use the command
Docker inspect-- format'{{.NetworkSettings.IPAddress}}'
Or
Docker inspect
Or
Docker inspect-f'{{range .NetworkSettings.Networks}} {{.IPAddress}} {{end}} 'container_name_or_id
3. You can consider writing a bash function in ~ / .bashrc:
Function docker_ip () {sudo docker inspect-- format'{{.NetworkSettings.IPAddress}}'$1}
Source ~ / .bashrc and then:
$docker_ip
172.17.0.6
4. It takes only one command to get all the container names and their IP addresses.
Docker inspect-f'{{.Name}}-{{.NetworkSettings.IPAddress}}'$(docker ps-aq)
If you use the docker-compose command, you will:
Docker inspect-f'{{.Name}}-{{range .NetworkSettings.Networks}} {{.IPAddress}} {{end}}'$(docker ps-aq)
5. Show all container IP addresses:
Docker inspect-- format=' {{.Name}}-{{range .NetworkSettings.Networks}} {{.IPAddress}} {{end}}'$(docker ps-aq) Thank you for reading! This is the end of the article on "how to get the ip address of the docker container (container)". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.