Clone AWS EC2 instance ( local )

A firm where I work asked me if it is possible to make some customisation to the frontend of a website that monitor GPS devices.
The webapp is running on an EC2 instance at AWS, where I can access from AWS Console and with SSH.
As OS Ubuntu Server 22.04.01 and it is based on Docker 20.10.21 ( I have the dockerfile ).
6-7 containers are running ( Nginx, Zinc, Mysql, TDEngine, Tomcat… ).
I would like to clone the whole app on a bare metal server, to avoid making modification on the production server.
Should I try to:

  • Clone the EC2 HD?
  • Reproduce the docker structure starting from the dockerfile?
  • Run the same containers manually and make the needed port connections? ( I do not think it is a good idea )
  • Clone the instance to another EC2 instance? ( it would be easy )

Thanks in advance for your help!

The provided information don’t realy allow to get the full picture and make a recommendation.

We don’t know if any additional aws services are used (which could be a problem on baremetal, and even more so when creating a snapshot of the volume and creating a new ec2 from it).

Are you sure they don’t use codebuild/codeploy to build the images and store them in ecr?

No AWS additional services are used.

They didn´t use codebuild/codeploy.

So all images are build locally and there is no registry involved?

It appears that creating a snapshot and then creating a new ec2 instance from the snapshot is the approach with the least effort.

Though, assumed everything is in git repos (including the compose files), why don’t you just check out the repos and bootstrap everything using the compose file from there? If the compose files have a build element, images that don’t exist will be created using the specified Dockerfiles.