tl;dr: use the Amazon Linux docker image (as @joostboonzajerflaes suggests), or an EC2 instance with an Amazon Linux AMI (@beau’s preferred method)
As you note, it is necessary to perform builds under amazon linux. This docs page provides the details on how various lambda runtimes map to the underlying environment.
There are two main ways to easily create an environment that will allow you to transfer builds into a lambda runtime.
You’ve already discovered one, which is to use a suitable docker container. For others’ reference, those docker images can be found here on docker hub.
Because docker is not part of my own dev workflow, I avoid it when possible. Instead, I spin up a suitable Amazon Linux EC2 instance for these builds. If you use the EC2 console to perform the launch, the appropriate Amazon Linux AMIs appear at the very top of their Quick Start list. Here is the complete list of AMI IDs by region and storage type.
What is the difference between Amazon Linux and Amazon Linux 2?
Glad you asked. This overview page provides the official explanation, but I’ve found it a bit hard to parse the distinction. If I understand correctly, AWS found their own AMI infrastructure somewhat limiting when providing LTS for their own operating system, so for AL2 they moved to a “base VM image + updatable packages” model. That said, you can still install AL2 from AMIs.
All that said, I use the python3.7 runtime for my lambdas, which (as one of the docs linked above says) uses the original Amazon Linux environment. And finally, I’ve unintentionally used AL2 for some of my python3.7 lambda builds, and they have worked just fine when deployed.
I hope I’m answering the question you have, but let me know.