docker安装mongodb

1.查找镜像

docker search mongo

2.拉取镜像

docker pull mongo

3.查看是否拉取成功

[root@mail easy-mock-dev]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mongo               latest              2b2cc1f48aed        7 days ago          388MB

4.创建挂载目录

mkdir -p /root/docker/mongo/db

5.通过镜像创建容器

docker run -p 27017:27017 -v /root/docker/mongo/db:/data/db --name mongo -d mongo

6.查看是否创建成功

[root@mail easy-mock-dev]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                      NAMES
b67bab61a5aa        mongo               "docker-entrypoint.s…"   14 minutes ago      Up 14 minutes       0.0.0.0:27017->27017/tcp   mongo

posted @ 2020-06-24 16:34  青阳闲云  阅读(1044)  评论(0编辑  收藏  举报