meteorhacks / meteord

MeteorD - Docker Runtime for Meteor Apps for Production Deployments
https://registry.hub.docker.com/u/meteorhacks/meteord/
MIT License
439 stars 371 forks source link

Access mongo@localhost failed #47

Open ghost opened 8 years ago

ghost commented 8 years ago

My mongodb is running inside an own container (tutum/mongodb) When I try to connect to it via localhost from meteorD connection fails

=> Starting meteor app on port:80

/bundle/bundle/programs/server/node_modules/fibers/future.js:278
                        throw(ex);
                              ^
Error: failed to connect to [localhost:27017]
    at Object.Future.wait (/bundle/bundle/programs/server/node_modules/fibers/future.js:398:15)
    at new MongoConnection (packages/mongo/mongo_driver.js:213:1)

However, when define the absolute url: mongodb://my-domain.com:27017 it works. After researching I came across this issue. The answer was to use docker run --net="host" ...

But, when I do this, I get an other error: EADDRINUSE because of port 80, which is reserved for the proxy. So I guess it's not good to share the host network, right.

So finally best practice would be to use the global mongodb uri?

btoueg commented 8 years ago

:+1:

hafeez1042 commented 8 years ago

:+1:

jkaberg commented 8 years ago

Wondering how to circumvent this aswell (besides the post by OP)?

jshimko commented 8 years ago

Localhost is not going to work in a container. Every container thinks it's a separate server.

Have you tried using Docker Compose as mentioned in the readme?

https://github.com/meteorhacks/meteord#22-with-docker-compose

# docker-compose.yml

dashboard:
  image: yourrepo/yourapp
  ports:
   - "80:80"
  links:
   - mongo
  environment:
   - MONGO_URL=mongodb://mongo:27017/yourapp # "mongo:27017" resolves to the internal IP of the container below
   - ROOT_URL=http://yourapp.com
   - MAIL_URL=smtp://some.mailserver.com:25

mongo:
  image: mongo:latest

docker-compose.yml links... https://docs.docker.com/compose/compose-file/#links