Docker Failed to connect to primary node for replica set # <Moped :: Cluster: 69840575665060 @seeds = [<Moped :: Node resolved_address = "127.0.0.1:27017">]>

I have two containers. The first container has a unicorn, and the second container has a mango.

  Name Command State Ports ------------------------------------------------------------------------------------- app_mongodb_1 /entrypoint.sh mongod Up 0.0.0.0:27017->27017/tcp app_web_1 foreman start Up 0.0.0.0:3000->3000/tcp 

When I try to access my rails application, the error not connect to a primary node for replica set #<Moped::Cluster:69840575665060 @seeds=[<Moped::Node resolved_address="127.0.0.1:27017">]> but when I log in with docker-compose web run rails c , I can save the document: f = Feature.new(name: "test", value: 10) => #<Feature _id: 565deac0616e642856000000, name: "test", value: 10, created_at: nil, updated_at: nil> => f.save => true

config / mongodb.yml

 development: sessions: default: database: app_development hosts: - mongodb options: options: test: sessions: default: database: app_test hosts: - mongodb options: read: primary max_retries: 1 retry_interval: 0 production: sessions: default: database: app_production hosts: - mongodb options: read: primary max_retries: 1 retry_interval: 0 

I do not understand that the error is at 127.0.0.1 , but I did not define this address in the configuration file.

/ etc / hosts

 172.17.0.3 mongodb 49ea2c077967 app_mongodb 
+5
source share

Source: https://habr.com/ru/post/1237185/


All Articles