1. After entering the inside of the container
Cat/etc/hosts
will display its own and (–link) soft connection to the container IP 2. Using Commands
Docker Inspect--format ' {{. Networksettings.ipaddress} ' <container-ID>
Or
Docker Inspect <container id>
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}} ' $
}
SOURCE ~/.BASHRC and then:
$ docker_ip <container-ID>
172.17.0.6 4. Only one command is required to obtain all container names and their IP addresses.
Docker Inspect-f ' {{. Name}}-{{. Networksettings.ipaddress} ' $ (Docker Ps-aq)
If you use the Docker-compose command, you will be:
Docker Inspect-f ' {{. Name}}-{{range. networksettings.networks}}{{. Ipaddress}}{{end} ' $ (Docker Ps-aq)
5. Display all container IP addresses:
Docker Inspect--format= ' {{. Name}}-{{range. networksettings.networks}}{{. Ipaddress}}{{end} ' $ (Docker Ps-aq)