@anarchopunk_girl if you don't want to edit the hosts file, then setting up custom DNS rules would probably be the next best solution. You could either run your own DNS server or use something like NextDNS.
Each docker container should have an IP on an internal network (depending on the containers network settings).