因为按照文档的方法构建镜像的时候就会报错
docker build -t shiyanloumongodb:1.0 .
Sending build context to Docker daemon 3.584kB
Step 1/16 : FROM ubuntu:14.04
---> 8cef1fa16c77
Step 2/16 : RUN echo "deb http://mirrors.aliyuncs.com/ubuntu/ trusty main universe" > /etc/apt/sources.list
---> Running in 8ede2e7947c1
Removing intermediate container 8ede2e7947c1
---> 781149632394
Step 3/16 : RUN apt-get -yqq update && apt-get install -yqq supervisor
---> Running in 73377daf605d
W: Failed to fetch http://mirrors.aliyuncs.com/ubuntu/dists/trusty/InRelease
W: Failed to fetch http://mirrors.aliyuncs.com/ubuntu/dists/trusty/Release.gpg Unable to connect to mirrors.aliyuncs.com:http:
W: Some index files failed to download. They have been ignored, or old ones used instead.
E: Unable to locate package supervisor
The command '/bin/sh -c apt-get -yqq update && apt-get install -yqq supervisor' returned a non-zero code: 100
所以我把DOKERFILE改成了下面这种
FROM ubuntu:latest
RUN apt-get update && apt-get install -yqq supervisor && apt-get clean
RUN apt-get install -yqq openssh-server openssh-client
RUN mkdir /var/run/sshd
RUN echo 'root:shiyanlou' | chpasswd
RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN apt-get install -y mongodb
RUN mkdir -p /data/db
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 27017 22
CMD ["supervisord"]```
supervisor.conf
[supervisord]
nodaemon=true
[program:mongod]
command=/usr/bin/mongod
[program:ssh]
command=/usr/sbin/sshd -D
➜ dmogodb docker run -d -P --name shiyanloumongodb mongo:3.0
ea7ff71538956373d5549590f0281cd746189e397b85914b8a0da499f852992a
➜ dmogodb mongops
zsh: command not found: mongops
➜ dmogodb docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ea7ff7153895 mongo:3.0 "mongod" 6 seconds ago Up 8 seconds 0.0.0.0:32791->22/tcp, 0.0.0.0:32790->27017/tcp shiyanloumongodb
容器运行起来了 但是连不上
➜ ~ mongo --host 127.0.0.1 --port 32790
MongoDB shell version v3.6.4
connecting to: mongodb://127.0.0.1:32790/
2018-05-19T19:44:10.094+0800 E QUERY [thread1] Error: network error while attempting to run command 'isMaster' on host '127.0.0.1:32790' :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed```
我试过起一个ubuntu:14.04的容器 attach进去装mongodb 。然后运行mongod 再出来链接是可以链接上的
不知道这个是哪里有问题
这种应该怎么调试呢?