Skip to content

Instantly share code, notes, and snippets.

@aloha1003
Created April 2, 2015 02:26
Show Gist options
  • Save aloha1003/321211cd1ba8a5ec3bbe to your computer and use it in GitHub Desktop.
Save aloha1003/321211cd1ba8a5ec3bbe to your computer and use it in GitHub Desktop.
How to access mongodb from outside
我透過docker-compose 安裝mongodb
腳本如下:
mongo:
image: aloha1003/mongo:latest
ports:
- "27017:27017"
- "28017:28017"
volumes:
- "/Volumes/MACOS/mongodb/var/mongodb:/srv/mongodb"
- "/Volumes/MACOS/log/mongodb:/var/log/mongodb"
其中的 aloha1003/mongo:latest的 Docker file是這樣寫
FROM mongo
COPY mongodb.conf /etc/mongodb.conf
CMD ["mongod", "-g", "daemon off;"]
我執行docker-compose up之後
執行docker ps 的結果
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a47277684787 aloha1003/mongo:latest "/entrypoint.sh mong 45 seconds ago Up 43 seconds 0.0.0.0:27017->27017/tcp, 0.0.0.0:28017->28017/tcp builddev_mongo_1
可是 我想要 在 外部用mongodb 的client 端軟體 去連 mongodb
卻一直連不到
請問該怎麼解決
@William-Yeh
Copy link

mongod 沒有 -g "daemon off" 參數;那是給 nginx 用的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment