docker-mongo集群我的库

[root@c7-o12c-5 ~]# cat dockerfile

FROM docker.io/centos  

RUN yum install -y unzip zip

RUN yum install -y net-tools  

# '***** mongodb ******'  

ADD mongodb-linux-x86_64-rhel70-3.4.4.tgz/usr/local/

RUN ln -s/usr/local/mongodb-linux-x86_64-rhel70-3.4.4 /usr/local/mongodb

ADD mongodb/ /usr/local/mongodb

#RUN chmod -R 755/usr/local/mongodb-3.4.4

RUN echo 'exportPATH=$PATH:/usr/local/mongodb/bin'>>/etc/bashrc

RUN source /etc/bashrc

EXPOSE 27017

 

[root@c7-o12c-5 ~]# cat mongodb/mongodb.cnf

dbpath=/usr/local/mongodb/data/db

logpath=/usr/local/mongodb/data/log/mongodb.log

logappend=true

httpinterface=true

port=27017

rest=true

pidfilepath=/usr/local/mongodb/data/run/mongo.pid

replSet=mydbCluster

oplogSize=512

[root@c7-o12c-5 ~]# ls mongodb/

data mongodb.cnf

[root@c7-o12c-5 ~]#

 

[root@c7-o12c-5 ~]# docker images

REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE

mymongo                   latest              1ccea8c2450e        7 minutes ago       575.8 MB

docker.io/centos          latest              196e0ce0c9fb        2 weeks ago         196.6 MB

 [root@c7-o12c-5~]# docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                      NAMES

bcef6a4027ef        mymongo             "/bin/bash"         4 minutes ago       Up 4 minutes        0.0.0.0:23017->27017/tcp   mongodb3

ffc7be2b1798        mymongo             "/bin/bash"         4

 

[root@c7-o12c-5 ~]# docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

[root@c7-o12c-5 ~]# docker ps -a

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                       PORTS               NAMES

bcef6a4027ef        mymongo             "/bin/bash"         7 hours ago         Exited (137) 8 minutes ago                       mongodb3

ffc7be2b1798        mymongo             "/bin/bash"         7 hours ago         Exited (137) 8 minutes ago                       mongodb2

ec5a4627f239        mymongo             "/bin/bash"         7 hours ago         Exited (137) 8 minutes ago                       mongodb1

1e4e06e9eff3        mynode              "npm start"         25 hours ago        Exited (1) 5 hours ago                           webnode

[root@c7-o12c-5 ~]# docker start mongodb1

mongodb1

[root@c7-o12c-5 ~]# docker start mongodb2

mongodb2

[root@c7-o12c-5 ~]# docker start mongodb3

mongodb3

[root@c7-o12c-5 ~]# docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                      NAMES

bcef6a4027ef        mymongo             "/bin/bash"         7 hours ago         Up 3 seconds        0.0.0.0:23017->27017/tcp   mongodb3

ffc7be2b1798        mymongo             "/bin/bash"         7 hours ago         Up 10 seconds       0.0.0.0:22017->27017/tcp   mongodb2

ec5a4627f239        mymongo             "/bin/bash"         7 hours ago         Up 21 seconds       0.0.0.0:21017->27017/tcp   mongodb1

[root@c7-o12c-5 ~]# docker exec -itmongodb1

/usr/bin/docker-current: "exec"requires a minimum of 2 arguments.

See '/usr/bin/docker-current exec --help'.

 

Usage:    dockerexec [OPTIONS] CONTAINER COMMAND [ARG...]

 

Run a command in a running container

[root@c7-o12c-5 ~]# docker exec -itmongodb1 /bin/bash

[root@ec5a4627f239 /]#

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值