[GODRIVER-902] Connect to Atlas within Docker Container Created: 25/Mar/19  Updated: 11/Apr/20  Resolved: 25/Mar/19

Status: Closed
Project: Go Driver
Component/s: Connections
Affects Version/s: 1.0.0-rc2
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Felix Leber Assignee: Unassigned
Resolution: Done Votes: 0
Labels: atlas, docker, golang
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Docker version 18.09.2, build 6247962
go.mongodb.org/mongo-driver v1.0.0/1c3b9b9
Multistage-Docker-build with: golang:1.12 & ubuntu:18.04



 Description   

When I shipped my Go application with Docker, I couldn't connect to the mongoDB atlas cluster anymore. Running it locally was not a problem. I can also reach the atlas cluster with the Mongo shell from inside the container. Connecting to a local instance of mongoDB inside another container is also no problem. 

 

URL:

mongodb+srv://<USER>:<PASSWORD>@<Cluster-Name>.gcp.mongodb.net/test?retryWrites=true 

Error: 

2019/03/25 18:05:34 Mongodb-Ping failed:server selection error: server selection timeout
 current topology: Type: ReplicaSetNoPrimary
 Servers:
 Addr: tarsi-test-shard-00-00-jr80d.gcp.mongodb.net:27017, Type: Unknown, State: Connected, Avergage RTT: 0, Last error: x509: certificate signed by unknown authority
 Addr: tarsi-test-shard-00-01-jr80d.gcp.mongodb.net:27017 ...



 Comments   
Comment by Matt Wong [ 11/Apr/20 ]

Yes it did, thanks Divjot.

Comment by Divjot Arora (Inactive) [ 10/Apr/20 ]

mwong17@cmc.edu Did updating the IP whitelist fix your connectivity issues?

Comment by Matt Wong [ 10/Apr/20 ]

Ahh, whitelisted IP addresses...

Comment by Matt Wong [ 10/Apr/20 ]

@ian.whalen did you resolve this? I'm having the same issue.

Comment by Felix Leber [ 25/Mar/19 ]

@ian.whalen

I used the syntax from the GoDoc 

client, err := NewClient(options.Client().ApplyURI("mongodb://foo:bar@localhost:27017"))

and replaced the credentials and url with the connection string which I received from the Atlas Dashboard. As it worked on my host system, I assumed it was correct.

Did I miss anything?

Comment by Ian Whalen (Inactive) [ 25/Mar/19 ]

email@felixleber.de looks like what you want to do here is pass in an SSL CA file as a connection string option.

Generated at Thu Feb 08 08:35:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.