I have a Singularity container using Ubuntu in which I install MongoDB. My original recipe had those lines to do so:
# get MongoDB
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
apt update
apt-get install -y mongodb-org
This worked very well in the past months. But now suddenly it doesn’t, resulting in the following output:
+ apt-get install -y mongodb-org
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed:
mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell
mongodb-org-tools
0 upgraded, 5 newly installed, 0 to remove and 3 not upgraded.
Need to get 98.0 MB of archives.
After this operation, 297 MB of additional disk space will be used.
Get:1 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 mongodb-org-shell amd64 4.2.11 [12.1 MB]
Get:2 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 mongodb-org-server amd64 4.2.11 [18.7 MB]
Get:3 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 mongodb-org-mongos amd64 4.2.11 [10.2 MB]
Get:4 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 mongodb-org-tools amd64 4.2.11 [57.0 MB]
Get:5 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2/multiverse amd64 mongodb-org amd64 4.2.11 [3524 B]
Fetched 98.0 MB in 3s (33.5 MB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package mongodb-org-shell.
(Reading database ... 53208 files and directories currently installed.)
Preparing to unpack .../mongodb-org-shell_4.2.11_amd64.deb ...
Unpacking mongodb-org-shell (4.2.11) ...
Selecting previously unselected package mongodb-org-server.
Preparing to unpack .../mongodb-org-server_4.2.11_amd64.deb ...
Unpacking mongodb-org-server (4.2.11) ...
Selecting previously unselected package mongodb-org-mongos.
Preparing to unpack .../mongodb-org-mongos_4.2.11_amd64.deb ...
Unpacking mongodb-org-mongos (4.2.11) ...
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../mongodb-org-tools_4.2.11_amd64.deb ...
Unpacking mongodb-org-tools (4.2.11) ...
Selecting previously unselected package mongodb-org.
Preparing to unpack .../mongodb-org_4.2.11_amd64.deb ...
Unpacking mongodb-org (4.2.11) ...
Setting up mongodb-org-shell (4.2.11) ...
Setting up mongodb-org-mongos (4.2.11) ...
Setting up mongodb-org-tools (4.2.11) ...
Setting up mongodb-org-server (4.2.11) ...
Adding system user `mongodb' (UID 104) ...
Adding new user `mongodb' (UID 104) with group `nogroup' ...
Not creating home directory `/home/mongodb'.
Adding group `mongodb' (GID 106) ...
Done.
Adding user `mongodb' to group `mongodb' ...
Adding user mongodb to group mongodb
Done.
/var/lib/dpkg/info/mongodb-org-server.postinst: 43: /var/lib/dpkg/info/mongodb-org-server.postinst: systemctl: not found
dpkg: error processing package mongodb-org-server (--configure):
installed mongodb-org-server package post-installation script subprocess returned error exit status 127
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
Errors were encountered while processing:
mongodb-org-server
mongodb-org
E: Sub-process /usr/bin/dpkg returned an error code (1)
ABORT: Aborting with RETVAL=255
As in ran fine in the past, and as this follows the installation tutorial on https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/, I thought that maybe I need a newer version, the old one not being supported in some way. So I changed it to 4.4.
Also I added an install for gnupg, as that is one thing mentioned in the tutorial (although for another problem). And given one answer in MongoDB installation problems Linux Mint Debian, I added touch /etc/init.d/mongod
.
Another possibility was that systemctl is not correcctly installed, and just in case I added lines that do that.
This resulted in the following new lines:
apt-get install -y systemd
touch /etc/init.d/mongod
apt-get install -y gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list
apt-get update
apt-get install -y mongodb-org
This results in a different error:
+ apt-get install -y mongodb-org
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
mongodb-org : Depends: mongodb-org-shell but it is not going to be installed
Depends: mongodb-org-server but it is not going to be installed
Depends: mongodb-org-mongos but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
ABORT: Aborting with RETVAL=255
I have no idea what else to do.
Edit: I made a minimal complete test suite to reproduce the error. Create a file test.recipe with the following content:
Bootstrap: docker
From: ubuntu:18.04
%post
apt update
apt-get install -y wget
apt-get install -y systemd
touch /etc/init.d/mongod
apt-get install -y gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list
apt-get update
apt-get install -y mongodb-org
%runscript
echo "Test"
And build an image with the following commands:
export SINGULARITY_LOCALCACHEDIR=$PWD
export SINGULARITY_CACHEDIR=$PWD
export SINGULARITY_TMPDIR=$PWD
export SINGULARITY_PULLFOLDER=$PWD
sudo singularity build test.img test.recipe
Edit:
I tried to install mongodb-org-shell
on it’s own. This yielded:
+ apt-get install -y mongodb-org-shell
[...]
The following packages have unmet dependencies:
mongodb-org-shell : Depends: libc6 (>= 2.29) but 2.27-3ubuntu1.3 is to be installed
Depends: libgcc-s1 (>= 4.2) but it is not installable
I tried to update libc6
by calling apt-get install -y libc6
but this had no effect.
2
Answers
I solved my problem. After trying out to manually install mongodb-org-shell and by that finding out that libc6 is not of a high enough version, in https://askubuntu.com/questions/1143268/how-to-install-a-libc6-version-2-29 I read that a higher version is standard for Ubuntu 20.04.
Given that, I had my image using Ubuntu 20.04 instead of the Ubuntu 18.04 as used before, and now everything works as once before.
I assume that the
mongodb-org
package was recently updated and is not compatible with older environments anymore.I faced a similar problem, with the error
See a solution here in this other SO post. I fixed it by adding:
in my Dockerfile because I don’t use
systemctl
in my container at all.This comes from a change in Mongo server 4.3+ that has been backported to 4.2 recently (around October 15) and introduced a call to
systemctl reload-daemon
in the post-install script. The Debian package must have been updated last week and broke the build for some of us.I wrote about this problem with more details on my website