title: How to connect to mongo database in docker from another machine using ruby code
body: <p>In my ruby code, I'm trying to use <code>Mongo::Client.new("mongodb://#{uname}:#{passwd}@#{host}:#{port}/#{db}")</code> to connect to a mongo database on another machine's docker in Kubernetes cluster. </p>
  
  <p>But the result says that </p>
  
  <blockquote>
    <p>getaddrinfo: Name or service not known. <code>#&lt;Mongo::Client:0x16434420 cluster=#&lt;Cluster
    topology=ReplicaSetNoPrimary[ip:port,mongo-0.mongo-hs.db.svc.cluster.local:27017,mongo-1.mongo-hs.db.svc.cluster.local:27017,mongo-2.mongo-hs.db.svc.cluster.local:27017,name=MainRepSet]
    servers=[#&lt;Server address=mongo-0.mongo-hs.db.svc.cluster.local:27017
    UNKNOWN&gt;,#&lt;Server address=mongo-1.mongo-hs.db.svc.cluster.local:27017
    UNKNOWN&gt;,#&lt;Server address=mongo-2.mongo-hs.db.svc.cluster.local:27017
    UNKNOWN&gt;]&gt;&gt;</code></p>
  </blockquote>
  
  <p>However, when I use <code>pymongo</code> in a python script. I can connect to the database.</p>
  
  <p>Is there a way for ruby code to connect to the database directly?</p>