The --format
option of inspect
comes to the rescue.
Modern Docker client syntax is:
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container_name_or_id
Old Docker client syntax is:
docker inspect --format '{{ .NetworkSettings.IPAddress }}' container_name_or_id
These commands will return the Docker container's IP address.
As mentioned in the comments: if you are on Windows, use double quotes "
instead of single quotes '
around the curly braces.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…