Here is my docker-compose file
version: "3.8"
services:
mongodb:
image: mongo
restart: always
container_name: mongodb_container_gold_jar
ports:
- 27017:27017
environment:
MONGO_INITDB_DATABASE: root
MONGO_INITDB_ROOT_USERNAME: haolamongodb
MONGO_INITDB_ROOT_PASSWORD: haolamongodb1210
volumes:
# named volumes
- mongodb_gold_jar:/data/db
- mongoconfig_gold_jar:/data/configdb
And here is my connection string: mongodb://haolamongodb:haolamongodb1210@127.0.0.1:27017/root
.
I also try to use localhost
instead of 127.0.0.1
but it still does not work
I have searched a lot but still got stuck on this, so pls help me figure it out. Thanks