I frequently have to test code on Amazon Linux 2 - both for work and for the PowerShell Core universal install script install-powershell.sh that I help maintain on the PowerShell Open Source project.
Spinning up an instance on Amazon is not a hassle, unless of course, you compare it to spinning up a container. Amazon Linux 2 container images are necessarily super-optimized to run as a container host for applications - so they have many packages removed compared to an Amazon Linux 2 EC2 AMI build.
But when I am testing something that will run on the full EC2 build, I’d still like to use a container.
Full EC2 Build in a Container For Testing
To satisfy this requirement I have created a full ec2 build container that has all the same packages. It can be pulled with this command:
docker pull darwinjs/amazonlinux2ec2build
To be quite clear, I would never use this container as a foundation for building a containerized application using Amazon Linux 2 containers. Following standard container engineering practices, the base amazon container should be leveled up with the minimum possible packages to get it ready for an given microservice.
This approach is strictly for quick and dirty testing - usually of shell scripts that don’t have dependencies on an full amazon environment being available.
Under the same approach - testing only - I have also put together an Amazon Linux 2 PowerShell Core container that layers on the bare minimum to get PowerShell Core operational. It can be accessed as such:
docker pull darwinjs/amazonlinux2powershell
The Power Of Stars
If you find either of the images useful, please let me know by adding a star to it in the docker repository so I know to keep investing in it :)
Code for this Article
The below repositories contain the images and teh source files for building them using Gitlab CI.