Google Cloud Shell [Link] is a free cloud service for running shell commands on a Debian-based distribution.

It runs on a shared VM with 16GB of RAM, 4 vCPUs, and 5GB of storage. Usage is limited to 50 hours per week, and the instance resets 20 minutes after logging out.

Note: No inbound ports are open to the internet. Only HTTP traffic is allowed through a reverse proxy (multi-handler will not work).

sudo docker pull metasploitframework/metasploit-framework
sudo docker run --name msf --rm -it -p 443:443 -v ${PWD}:/root/.msf4 metasploitframework/metasploit-framework

An alternative is Kali + Top 10 Tools:

sudo docker pull kalilinux/kali-rolling
sudo docker run --name kali -ti kalilinux/kali-rolling /bin/bash

Then set up the environment:

apt update && apt dist-upgrade -y && apt autoremove && apt clean
apt install kali-tools-top10

Image sizes before setup:

REPOSITORY                                  SIZE
metasploitframework/metasploit-framework    1.21GB
kalilinux/kali-rolling                      125MB

And after installing the Kali tools:

NAME   IMAGE                    SIZE
kali   kalilinux/kali-rolling   2.92GB (virtual 3.04GB)

Another option is The PenTesters Framework (PTF):

sudo docker run --name ptf -ti kalilinux/kali-rolling /bin/bash

Then run:

apt update && apt dist-upgrade -y && apt autoremove && apt clean
apt install git pip -y
git clone https://github.com/trustedsec/ptf.git
cd ptf
pip install -r requirements.txt
./ptf

Inside PTF, install Metasploit:

use modules/exploitation/metasploit
install

Final size after installing PTF + Metasploit on Kali:

NAME   IMAGE                    SIZE
ptf    kalilinux/kali-rolling   1.97GB (virtual 2.09GB)