第一步:
最好还是执行:yum -y update,这样的话yum会有最新的mongodb镜像
第二步:
runoob@runoob:~/mongo$ docker pull mongo:3.2
我选的是mongo3.2的镜像,至于镜像之间的区别本人不清楚。在执行这一步的时候,有时候会遇到一下两种情况吧(这是我遇到的两种)。
第一种:[root@iZoy1sqyolh244Z ~]# docker pull mongo:3.2
Pulling repository docker.io/library/mongo
Get https://registry-1.docker.io/v1/repositories/library/mongo/tags/3.2: dial tcp: lookup registry-1.docker.io on 100.100.2.136:53: read udp 172.18.5.237:35736->100.100.2.136:53: i/o timeout
第二种:[root@iZoy1sqyolh244Z ~]# docker pull mongo:3.2
Pulling repository docker.io/library/mongo
Tag 3.2 not found in repository docker.io/library/mongo
[root@iZoy1sqyolh244Z ~]# docker pull mongo:3.2
3.2: Pulling from library/mongo
386a066cd84a: Already exists
524267bc200a: Pulling fs layer
476d61c7c43a: Pulling fs layer
0750d0e28b90: Pulling fs layer
4bedd83d0855: Waiting
162b67684652: Waiting
46f53b7d829e: Waiting
cef8f3d7f866: Waiting
2272eba3cacc: Waiting
error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/registry-v2/docker/registry/v2/blobs/sha256/c5/c5185a5940643c0d212083b3b6275bb2f149030530fea44e12be861186293451/data?Expires=1481715213&Signature=MmpoQcqUnHnM17Vzi6XAqTlyZi-ZDAuFKsyV7W9Gw-KfGre1xyM7RQdyiuqBWSVrNKeLWRjbu4j7iNv6DE4BgkTqaCPeq47mSW5pz4OzwQsXXQcLm05KA6LfqYuKYh3pFEjlvLuDqfyfFtQnWdCA4n39rMBRj9gKQumbt23MkfY_&Key-Pair-Id=APKAJECH5M7VWIS5YZ6Q: dial tcp: lookup dseasb33srnrn.cloudfront.net on 100.100.2.136:53: read udp 172.18.5.237:58504->100.100.2.136:53: i/o timeout
其实在我看来这两种都算是一种情况,只不过第二种 的情况,自动运行的更深了一点。我的解决办法是,还是执行docker pull mongo:3.2此命令。
第三步:
[root@iZoy1sqyolh244Z ~]# docker run -d --name mongodb -p 27017:27017 -v $PWD/db:/data/db -d mongo:3.2
最后:
[root@iZoy1sqyolh244Z ~]# docker ps
CONTAINER IDIMAGECOMMANDCREATEDSTATUSPORTSNAMES
0bfea140b247mongo:3.2"/entrypoint.sh mongo"6 seconds agoUp 5 seconds0.0.0.0:27017->27017/tcpmongodb
OK,好了。