docker 安装mongodb

1.docker search mongo

2.docker pull mongo:3.2

使用mongo镜像

3.运行容器

runoob@runoob:~/mongo dockerrunp27017:27017v PWD/db:/data/db -d mongo:3.2
cda8830cad5fe35e9c4aed037bbd5434b69b19bf2075c8626911e6ebb08cad51
runoob@runoob:~/mongo$

4.命令说明:
-p 27017:27017 :将容器的27017 端口映射到主机的27017 端口
-v $PWD/db:/data/db :将主机中当前目录下的db挂载到容器的/data/db,作为mongo数据存储目录
查看容器启动情况

runoob@runoob:~/mongo dockerpsCONTAINERIDIMAGECOMMANDPORTSNAMEScda8830cad5fmongo:3.2/entrypoint.shmongo0.0.0.0:27017>27017/tcpsuspiciousgoodall使mongomongo,IP172.17.0.1runoob@runoob: /mongo docker run -it mongo:3.2 mongo –host 172.17.0.1MongoDB shell version:3.2.7
connecting to:172.17.0.1:27017/test
Welcome to the MongoDB shell.For interactive help, type “help”.For more comprehensive documentation, see
http://docs.mongodb.org/Questions?Try the support group
http://groups.google.com/group/mongodb-user>

你可能感兴趣的:(devops,数据库,系统)