Overlay2 driver takes long time to startup

Hello Guys.

My environment
Docker version 27.0.3, build 7d4bcd8
OS: Ubuntu 24.04 (EC2 Amazon)

Problem
Ovarlay2 driver takes around 9 minutes to load in a fresh AWS EC2 instance
After running systemctl status docker.service the logs shows:

Jul 12 19:17:01 ip-172-31-24-23 dockerd[1104]: time="2024-07-12T19:17:01.944094734Z" level=info msg="[graphdriver] trying configured driver: overlay2"
Jul 12 19:26:01 ip-172-31-24-23 dockerd[1104]: time="2024-07-12T19:26:01.263425405Z" level=info msg="Loading containers: start."

Which shows the cause of delay (overlay2).

Steps to reproduce
Step 1: create a t2.2xlarge EC2 instance (with the environment above)
Step 2: After docker installation add just one option to the daemon.json file

{
  "storage-driver": "overlay2"
}

Step 3: restart docker (it is fast, around 4 seconds)
Step 4: create an AMI using this instance
Step 5: create a new EC2 instance (t2.2xlarge) using the AMI from the previous step
Step 6: ssh the new running instance and run systemctl status docker.service. It will show that the service is still activating. It will take more than 9 minutes.

Anyone can figure out why the docker startup time in step 6 is significantly higher than the 4 seconds in step 3?

(Thank you in advance)

If this is an issue report, it should probably go into Github.

After several testing I was able to detect that this delay is because the docker images in the instance in the step 5. I have around 285 docker images inside. I imaging that the overlay driver needs to do an extra work with the image layers the first time the instance is loaded.