I don't know if this is the expected behavior, but if I run docker login from a container from docker image, it tries the following and fails:
$ docker run -ti --rm docker:dind ash
# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: me
Password:
error during connect: Post http://docker:2375/v1.40/auth: dial tcp: lookup docker on 8.8.8.8:53: no such host
As you can see, it tries (unsuccessfully) to connect to host docker and fails. Why? Is it expected?