-
-
Notifications
You must be signed in to change notification settings - Fork 127
Description
In the Network Manipulation Basics chapter there's a line that says:
"Keep in mind though, in order for the automatic DNS resolution to work you must assign custom names to the containers. Using the randomly generated name will not work"
Automatically generated names work perfectly fine for DNS resolution on custom bridge networks. Assuming two containers are on the same custom bridge network, pinging the 1st container from the 2nd container would work just fine even if ping command is given the generated name of the 1st container (let's say something line "practical_franklin"). If a container is given a '--network-alias' - it's reachable both by the alias and the '--name' (if given one) or the default name generated by the Docker if no custom name was given.
docker network create my-net
docker run --rm -d --network my-net nginx:latest
docker run --rm -it --name alpine --network my-net alpine:latestInside the alpine container issuing a ping command that reaches the nginx container (let's say by its auto-generated practical_franklin) will succeed with 0 packet loss.