[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 /]#