I used a similar technique to connect Compass to a remote server that had 3 instances of Mongo running as a replicated set with docker-compose. In my case, I modified /etc/hosts file to add the remote IP of the server hosting the docker containers as aliases for each named instance of mongo1, mongo2, and mongo3
± % more /etc/hosts !5622
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
192.168.1.141 mongo1
192.168.1.141 mongo2
192.168.1.141 mongo3