The mongo service need to have exposed ports as per the documentation.
Then, on the Dokku server run
dokku mongo:info <name>
take note of the internal ip of the Mongo server, exposed ports and the Mongo URI.
Then run
ssh -N -L 27017:<INTERNAL_IP>:27017 <USER>@<SERVER>
to create a port forwarding ssh-tunnel to the mongo instance.
Now you can connect to the db as if it was on localhost:27017
. Get the password from the Mongo URI.
If using the Mongo URI directly, change the host to localhost, i.e.:
mongodb://<name>:<password>@localhost:27017/<name>