You don’t, they’re different. (“localhost” always resolves to 127.0.0.1 and it’s a very magical IP address.)
If you’re seeing an IP address of 192.168.99.100 you’re probably using Docker Toolbox or Docker Machine, which is running Docker on a Linux VM, and that’s the default IP address of that VM. If you’re using one of these options to run Docker then you have to use the $(docker-machine ip)
address, usually 192.168.99.100. If you really want it to be “localhost” then you need to switch to the desktop-based Docker for Mac, or Docker for Windows, or just running Docker directly on your Linux host, as appropriate.