[TOC]

概述

方法一、docker pull mongo

查找Docker Hub上的mongo镜像

1
2
3
4
5
6
7
8
9
10
11
12
frewen@bogon  ~  docker search mongo
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mongo MongoDB document databases provide high avai… 6295 [OK]
mongo-express Web-based MongoDB admin interface, written w… 543 [OK]
tutum/mongodb MongoDB Docker image – listens in port 27017… 228 [OK]
bitnami/mongodb Bitnami MongoDB Docker Image 100 [OK]
mongoclient/mongoclient Official docker image for Mongoclient, featu… 77 [OK]
mongooseim/mongooseim Small docker image for MongooseIM - robust a… 18
frodenas/mongodb A Docker Image for MongoDB 17 [OK]
cvallance/mongo-k8s-sidecar Kubernetes side car to setup and maintain a … 13 [OK]
centos/mongodb-32-centos7 MongoDB NoSQL database server 8
arm64v8/mongo MongoDB document databases provide high avai… 6

这里我们拉取官方的镜像,标签为3.2

1
runoob@runoob:~/mongo$ docker pull mongo

等待下载完成后,我们就可以在本地镜像列表里查到REPOSITORY为mongo,标签为3.2的镜像。

1
2
3
4
5
6
7
8
9
 frewen@bogon  ~  docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mongo latest cda2c466f867 5 weeks ago 361MB
nginx latest 7042885a156a 10 months ago 109MB
ubuntu 16.04 4a689991aa24 12 months ago 116MB
ubuntu 14.04 f216cfb59484 12 months ago 188MB
ubuntu latest ea4c82dcd15a 12 months ago 85.8MB
busybox latest 59788edf1f3e 12 months ago 1.15MB
hello-world latest 4ab4c602aa5e 13 months ago 1.84kB

方法二、通过 Dockerfile 构建

这个我们可以参考:https://www.runoob.com/docker/docker-install-mongodb.html

使用mongo镜像

运行容器

由于我们现在的Docker里面已经运行了一个mongo的镜像实例,我们先停掉: