Can't reach keyserver hkp://keyserver.ubuntu.com:80 from container

I use LXD for local development tasks with WordPress.

I use trellis to provision servers and I swap out Vagrant for LXD for local development. Trellis uses Ansible to provision the local development environment and I have been using this setup successfully for years.

Yesterday I tried to provision a new LXD container and Ansible fails because the container can’t connect to the keyserver at hkp://keyserver.ubuntu.com:80.

Error fetching key F1656F24C74CD1D8 from keyserver:
hkp://keyserver.ubuntu.com:80
Warning: apt-key output should not be parsed (stdout is not a terminal)
gpg: keyserver receive failed: Connection timed out
fatal: [localdev.test]: FAILED! => {"changed": false, "cmd": "/usr/bin/apt-key adv --no-tty --keyserver hkp://keyserver.ubuntu.com:443 --recv F1656F24C74CD1D8", "rc": 2, "stderr_lines": ["Warning: apt-key output should not be parsed (stdout is not a terminal)", "gpg: keyserver receive failed: Connection timed out"], "stdout": "Executing: /tmp/apt-key-gpghome.A6l2dvB1tz/gpg.1.sh --no-tty --keyserver hkp://keyserver.ubuntu.com:443 --recv F1656F24C74CD1D8\n", "stdout_lines": ["Executing: /tmp/apt-key-gpghome.A6l2dvB1tz/gpg.1.sh --no-tty --keyserver hkp://keyserver.ubuntu.com:80 --recv F1656F24C74CD1D8"]}

I tried to import the required key manually:

root@localdev:~# apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 F1656F24C74CD1D8
Executing: /tmp/apt-key-gpghome.hgPpAErLkJ/gpg.1.sh --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 F1656F24C74CD1D8
gpg: keyserver receive failed: Connection timed out

The same command works as expected on the host machine.

Both host and container are running fully updated Ubuntu 20.04.4.

Any help gratefully received.