I have a basic node container
ROM node:boron
RUN npm install
EXPOSE 1337
CMD ["npm","start"]
but when launching it it tries to connect to mongodb://localhost:27017/my-bd
what is a local mongo on my mac...
This generates the following error:
Unable to ensure uniqueness for usernames: MongoNetworkError:
failed to connect to server [localhost:27017] on first connect
[MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
Any ideas?
Try deploying your container with the --netwok host option, or instead of telling it to connect to localhost:27017, tell it to connect to your host's ip.
This is because when you deploy your container it will have its own ip unless you tell it otherwise.
The machine where you have the docker engine (and mongo) will have an ip X, while the container will have an ip Y. When you tell the container to connect to localhost it will look at ip Y, when it should look at X.
My advice is that you modify the connector so that it connects to an address called mongohost (for example) and when you run the container, do it as follows:
With this you will be able to have the mongo server on any host that you specify to the container when you start it up.
I hope it helps.