5

I can't manage to install mongodb in a Ubuntu LXC container.

I've set-up the Ubuntu 14.10 host by following these instructions: https://linuxcontainers.org/lxc/getting-started/

lxc-create --version
1.1.0

Following the docs, I created the VM via the download template and selected a Ubuntu 14.10 amd64 guest (though I experience the same behaviour with 14.04 amd64):

I start attach myself to it

lxc-start -n test0 && lxc-attach -n test0

inside the container I run

apt-get update && apt-get install mongodb

The installation fails with the following output:

...
Setting up mongodb-clients (1:2.6.3-0ubuntu5) ...
Setting up mongodb-server (1:2.6.3-0ubuntu5) ...
Adding system user `mongodb' (UID 101) ...
Adding new user `mongodb' (UID 101) with group `nogroup' ...
Not creating home directory `/var/lib/mongodb'.
Adding group `mongodb' (GID 105) ...
Done.
Adding user `mongodb' to group `mongodb' ...
Adding user mongodb to group mongodb
Done.
start: Job failed to start
invoke-rc.d: initscript mongodb, action "start" failed.
dpkg: error processing package mongodb-server (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mongodb:
 mongodb depends on mongodb-server (>= 1:2.4.1-2); however:
  Package mongodb-server is not configured yet.

dpkg: error processing package mongodb (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.19-10ubuntu2.3) ...
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
 mongodb-server
 mongodb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Using a 14.04 container and the 10gen repo results in the same error:

start: Job failed to start
invoke-rc.d: initscript mongod, action "start" failed.
dpkg: error processing package mongodb-org-server (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up mongodb-org-mongos (3.0.0) ...
Setting up mongodb-org-tools (3.0.0) ...
dpkg: dependency problems prevent configuration of mongodb-org:
 mongodb-org depends on mongodb-org-server; however:
  Package mongodb-org-server is not configured yet.

Some searches suggest that the issue may be caused by insufficient disk space, but more than 15G is available, according to df -h on the host.

Running mongod as a command tells me that it's looking for a /data/db path. Creating it will allow me to run mongod, but running service mongodb start return start: Job failed to start.

I've tried on several different virtual and physical hosts, always the same error.

1 Answer 1

7

I bumped into similar issue a while ago in lxc with Ubuntu 14.04 as guest OS. I did some digging and it turned out that the limit nofile ... directive in mongodb upstart job somehow caused dpkg --configure call on mongodb-server package to exit with failure during mongodb post-installation process. Commenting the line allows the installation process to continue and complete successfully.

root@mongodb:~# apt install mongodb
...
Setting up mongodb-server (1:2.4.9-1ubuntu2) ...
start: Job failed to start
invoke-rc.d: initscript mongodb, action "start" failed.
dpkg: error processing package mongodb-server (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mongodb:
 mongodb depends on mongodb-server (>= 1:2.4.1-2); however:
  Package mongodb-server is not configured yet.

dpkg: error processing package mongodb (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
Processing triggers for ureadahead (0.100.0-16) ...
Errors were encountered while processing:
 mongodb-server
 mongodb
E: Sub-process /usr/bin/dpkg returned an error code (1)

root@mongodb:~# sed -i -r 's/^limit nofile/#&/' /etc/init/mongodb.conf 
root@mongodb:~# apt install mongodb
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mongodb is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
Setting up mongodb-server (1:2.4.9-1ubuntu2) ...
mongodb start/running, process 3447
Setting up mongodb (1:2.4.9-1ubuntu2) ...

root@mongodb:~# sed -i -r 's/^#limit nofile/limit nofile/' /etc/init/mongodb.conf
root@mongodb:~# initctl restart mongodb
mongodb start/running, process 3480
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .