this is quite late response, but I just did what you've asked and it works for me.
I'm using VPN connection to get access to my office which is running on ppp0 interface. I've run below and now I can access hostnames which are only available via vpn, without setting up option to send all traffic through VPN.
/sbin/route add -host -interface
If you are modifying /etc/hosts in the Docker container itself, then only processes within the Docker container are going to be able to resolve that domain locally.
Thus, if you are using a browser on your Mac to access a port exposed by Docker, it knows nothing about the DNS override and will try to hit the real site -- which likely explains the message ...
Edit your hosts file:
sudo vi /etc/hosts
Add URLs you want to block. This should be sufficient:
# Block YouTube
Reset the Directory Service cache
Ping the the hosts for ...