Docker无法连接到副本集的主节点#<moped :: cluster:69840575665060 @seeds =“[&lt; Moped :: Node”resolved_address =“127.0.0.1:27017”>]&gt;

时间:2015-12-01 19:00:27

标签: ruby-on-rails mongodb docker

我有两个容器。第一个容器有独角兽,第二个容器有mongod。

        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

当我尝试访问我的rails应用程序时返回错误not connect to a primary node for replica set #<Moped::Cluster:69840575665060 @seeds=[<Moped::Node resolved_address="127.0.0.1:27017">]>,但当我输入docker-compose web run rails c时,我可以保存文档: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

我不明白,错误是在127.0.0.1,但在配置文件中我还没有定义这个地址。

的/ etc /主机

172.17.0.3  mongodb 49ea2c077967 app_mongodb

0 个答案:

没有答案