Problems installing MongoDB in a container

I’m asking this in parallel on https://stackoverflow.com/questions/64967774/problem-installing-mongodb-in-container.

So, I have a singularity container recipe in which MongoDB is installed in an Ubuntu environment, which worked just fine in the last months. Now suddenly it doesn’t, without me having changed the instructions at that part.

My original lines were

	# 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

After having tried out several possible fixes on my own, my current lines are:

        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

The error message is:

+ 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 solved my problem by using a higher Ubuntu version in the setup of my container, went from 18.04 to 20.04.

My assumption is that the mongodb-org package was recently updated to something that is not compatible with my old environment anymore. I’m now considering limiting the version of the package somehow in order to reduce the required maintenance.