Docker上的Mongodb安装

时间:2015-09-08 00:00:46

标签: mongodb docker

我已经尝试了一段时间,以各种方式在我的码头图像上安装mongodb。我已经尝试使用官方图片来调用#docker pull mongo:latest'但由于某种原因,终端只是挂起而没有来自docker的反馈。我还试过各种方法通过Dockerfile构建它,但在尝试配置mongodb-org-server时遇到了问题。

在我的docker镜像上安装mongodb的正确方法是什么?我认为最简单的方法是将docker图像用于mongo,但这只是冻结。

Dockerfile

FROM ubuntu:12.04
FROM ruby:2.2.0

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list

RUN apt-get update -qq
RUN apt-get upgrade -y
RUN apt-get install -y build-essential libpq-dev nodejs mongodb-org tcl8.5

# Install redis
RUN wget http://download.redis.io/releases/redis-stable.tar.gz
RUN tar xzf redis-stable.tar.gz
WORKDIR redis-stable
RUN make
RUN make install

WORKDIR utils
RUN ./install_server.sh

RUN service redis_6379 start

RUN mkdir /myapp
WORKDIR /myapp

ADD . /myapp

RUN mv redis.conf /etc/redis/redis.conf.default
RUN redis-server &
#RUN bundle install
#RUN RAILS_ENV=development bundle exec rake assets:precompile --trace
RUN service mongod status
#RUN rake db:mongoid:create_indexes

CMD ["rails", "server", "-b", "0.0.0.0"]

ERROR

Step 6 : RUN apt-get install -y build-essential libpq-dev nodejs mongodb-org tcl8.5
 ---> Running in bc29e517b3a9
Reading package lists...
Building dependency tree...
Reading state information...
build-essential is already the newest version.
libpq-dev is already the newest version.
The following package was automatically installed and is no longer required:
  libbison-dev
Use 'apt-get autoremove' to remove it.
The following extra packages will be installed:
  libc-ares2 libtcl8.5 libv8-3.14.5 mongodb-org-mongos mongodb-org-server
  mongodb-org-shell mongodb-org-tools
Suggested packages:
  tcl-tclreadline
The following NEW packages will be installed:
  libc-ares2 libtcl8.5 libv8-3.14.5 mongodb-org mongodb-org-mongos
  mongodb-org-server mongodb-org-shell mongodb-org-tools nodejs tcl8.5
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 53.6 MB of archives.
After this operation, 168 MB of additional disk space will be used.
Get:1 http://repo.mongodb.org/apt/ubuntu/ precise/mongodb-org/3.0/multiverse mongodb-org-shell amd64 3.0.6 [4258 kB]
Get:2 http://http.debian.net/debian/ jessie/main libtcl8.5 amd64 8.5.17-1 [737 kB]
Get:3 http://repo.mongodb.org/apt/ubuntu/ precise/mongodb-org/3.0/multiverse mongodb-org-server amd64 3.0.6 [8632 kB]
Get:4 http://http.debian.net/debian/ jessie/main libc-ares2 amd64 1.10.0-2 [76.7 kB]
Get:5 http://http.debian.net/debian/ jessie/main nodejs amd64 0.10.29~dfsg-2 [648 kB]
Get:6 http://http.debian.net/debian/ jessie/main tcl8.5 amd64 8.5.17-1 [58.6 kB]
Get:7 http://http.debian.net/debian/ jessie/main libv8-3.14.5 amd64 3.14.5.8-8.1 [1269 kB]
Get:8 http://repo.mongodb.org/apt/ubuntu/ precise/mongodb-org/3.0/multiverse mongodb-org-mongos amd64 3.0.6 [4043 kB]
Get:9 http://repo.mongodb.org/apt/ubuntu/ precise/mongodb-org/3.0/multiverse mongodb-org-tools amd64 3.0.6 [33.8 MB]
Get:10 http://repo.mongodb.org/apt/ubuntu/ precise/mongodb-org/3.0/multiverse mongodb-org amd64 3.0.6 [3616 B]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 53.6 MB in 11s (4850 kB/s)
Selecting previously unselected package libtcl8.5:amd64.
(Reading database ... 27887 files and directories currently installed.)
Preparing to unpack .../libtcl8.5_8.5.17-1_amd64.deb ...
Unpacking libtcl8.5:amd64 (8.5.17-1) ...
Selecting previously unselected package libc-ares2:amd64.
Preparing to unpack .../libc-ares2_1.10.0-2_amd64.deb ...
Unpacking libc-ares2:amd64 (1.10.0-2) ...
Selecting previously unselected package libv8-3.14.5.
Preparing to unpack .../libv8-3.14.5_3.14.5.8-8.1_amd64.deb ...
Unpacking libv8-3.14.5 (3.14.5.8-8.1) ...
Selecting previously unselected package mongodb-org-shell.
Preparing to unpack .../mongodb-org-shell_3.0.6_amd64.deb ...
Unpacking mongodb-org-shell (3.0.6) ...
Selecting previously unselected package mongodb-org-server.
Preparing to unpack .../mongodb-org-server_3.0.6_amd64.deb ...
Unpacking mongodb-org-server (3.0.6) ...
Selecting previously unselected package mongodb-org-mongos.
Preparing to unpack .../mongodb-org-mongos_3.0.6_amd64.deb ...
Unpacking mongodb-org-mongos (3.0.6) ...
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../mongodb-org-tools_3.0.6_amd64.deb ...
Unpacking mongodb-org-tools (3.0.6) ...
Selecting previously unselected package mongodb-org.
Preparing to unpack .../mongodb-org_3.0.6_amd64.deb ...
Unpacking mongodb-org (3.0.6) ...
Selecting previously unselected package tcl8.5.
Preparing to unpack .../tcl8.5_8.5.17-1_amd64.deb ...
Unpacking tcl8.5 (8.5.17-1) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_0.10.29~dfsg-2_amd64.deb ...
Unpacking nodejs (0.10.29~dfsg-2) ...
Processing triggers for systemd (215-17+deb8u2) ...
Setting up libtcl8.5:amd64 (8.5.17-1) ...
Setting up libc-ares2:amd64 (1.10.0-2) ...
Setting up libv8-3.14.5 (3.14.5.8-8.1) ...
Setting up mongodb-org-shell (3.0.6) ...
Setting up mongodb-org-server (3.0.6) ...
Adding system user `mongodb' (UID 105) ...
Adding new user `mongodb' (UID 105) with group `nogroup' ...
Not creating home directory `/home/mongodb'.
Adding group `mongodb' (GID 109) ...
Done.
Adding user `mongodb' to group `mongodb' ...
Adding user mongodb to group mongodb
Done.
invoke-rc.d: unknown initscript, /etc/init.d/mongod not found.
dpkg: error processing package mongodb-org-server (--configure):
 subprocess installed post-installation script returned error exit status 100
Setting up mongodb-org-mongos (3.0.6) ...
Setting up mongodb-org-tools (3.0.6) ...
dpkg: dependency problems prevent configuration of mongodb-org:
 mongodb-org depends on mongodb-org-server; however:
  Package mongodb-org-server is not configured yet.

dpkg: error processing package mongodb-org (--configure):
 dependency problems - leaving unconfigured
Setting up tcl8.5 (8.5.17-1) ...
Setting up nodejs (0.10.29~dfsg-2) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for libc-bin (2.19-18+deb8u1) ...
Errors were encountered while processing:
 mongodb-org-server
 mongodb-org
E: Sub-process /usr/bin/dpkg returned an error code (1)
Service 'web' failed to build: The command '/bin/sh -c apt-get install -y build-essential libpq-dev nodejs mongodb-org tcl8.5' returned a non-zero code: 100

2 个答案:

答案 0 :(得分:0)

我认为这是https://stackoverflow.com/a/16575040/880056

的副本

总结:您正在尝试安装为Upstart init服务打包的新版MongoDB,但您正在运行的Ubuntu版本仍使用SysV init脚本。

您使用如此旧的Ubuntu版本(12.04)的原因是什么?

答案 1 :(得分:0)

这样做:

docker run --name MongoDB -p 27017:27017 --restart=always -d mongo