Replies: 14 comments
-
The first example works for me |
Beta Was this translation helpful? Give feedback.
-
@LaurentGoderre , I've made sure to update my docker desktop and I am still facing the same issue: It ends with it stating |
Beta Was this translation helpful? Give feedback.
-
Though if I add ports to the above mongo, then I can connectusing mongodb://root:example@localhost:27017. Of course I assume this isn't ideal to just expose ports as such. |
Beta Was this translation helpful? Give feedback.
-
The hostname |
Beta Was this translation helpful? Give feedback.
-
I wonder also if it is PC related as my own rig works fine, but work laptop refuses no matter what. Now, regarding what you mentioned about the hostname part with mongo. Does this mean it is only exposed to the other containers defined in my compose file ( a bit new to docker)? If so, how would I then have my locally running api hit my mongo container if I decide against also exposing port 27017? |
Beta Was this translation helpful? Give feedback.
-
If you are running on a Linux host, you can hit the container's ip address directly. $ docker container inspect mongo --format '{{ .NetworkSettings.IPAddress }}
172.17.0.2 But there could be more than one network that the container is on, so might need to look through all the network settings: $ docker container inspect mongo --format '{{ json .NetworkSettings }}' | jq |
Beta Was this translation helpful? Give feedback.
-
In the docker-compose example the mongo-express container won't start because it is getting Authentication failed error. Does anyone else have the same problem? |
Beta Was this translation helpful? Give feedback.
-
@svili the documentation as is or did you try to customize the db name? |
Beta Was this translation helpful? Give feedback.
-
Running the example docker-compose on the documentation as is.
I'm on Linux, updated my docker to the latest version, trying to run it with the docker compose plugin. |
Beta Was this translation helpful? Give feedback.
-
@svili Can you try explicitly linking the services? # Use root/example as user/password credentials
version: '3.1'
services:
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
links:
- mongo
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/ |
Beta Was this translation helpful? Give feedback.
-
It's the same. While via this most minimal docker-compose, which is supposed to be equivalent, I get
I'm running this via |
Beta Was this translation helpful? Give feedback.
-
There is still a volume created for persistence so you might need to add |
Beta Was this translation helpful? Give feedback.
-
Hey guys, I would like to share with you this snippet to connect a local container instance. And I created the container with: So, in my mongodb compass, I choose the connection by username and password option: And then, the connect was successfuly. the connection string was created as: The documentation seems a little confusing, but it was helpful to me. |
Beta Was this translation helpful? Give feedback.
-
If you check the docker logs of the mongo-express, the default credentails for mongo-express image is admin:pass which is different from mongo root user and password |
Beta Was this translation helpful? Give feedback.
-
I've been trying to connect to my local docker instance this morning without much avail after following the steps laid out in the official documentation. I made my dockerfile look like so:
Exact copy, I keep getting connection timeout. Server selection timeout to be exact per the express logs. HOWEVER, if I were to use an older docker compose file I had from some time ago:
I can connect just fine. The ctx I was trying to use in the Compass GUI application was:
mongodb://root:example@mongo:27017/
. I have also tried adding a specific authSource didn't do it. Connecting to the latter variant works well by using eithermongodb://kovalsky:kovalsky@localhost:27017/?authSource=admin&readPreference=primary&appname=MongoDB%20Compass&ssl=false
or the same without the query string.Where exactly am I going awry?
Beta Was this translation helpful? Give feedback.
All reactions