…yeah, never do this. It will give you an artificial IP address that’s useless for most purposes. That’s doubly true if you’re in an environment like either of the Mac-based environments where Docker is running in a virtual machine: the host simply can’t reach the fake 172.17.0.0/16 Docker network.
You should treat the fact that containers happen to have IP addresses as an implementation detail, use the normal
docker run -p option to publish ports on your host, and use your host’s DNS name (or IP address) and the published ports to access your containers.
(The further corollary to this, which you should absolutely Google, is that you should never say
localhost in a Docker world, except in the extremely specific case of you, the human, sitting at the keyboard and typing it into a browser or tool running on your desktop to get access to a container’s published port.)