Hi@akhtar,
In a configuration especially a container setup such as Docker where the inventory file keeps constantly changing as you add or decommission servers, keeping tabs on the hosts defined in the inventory file becomes a real challenge. It becomes inconvenient going back to the host file and updating the list of hosts with their IP addresses. And this is where a dynamic inventory comes to play. You can find some scripts in python for docker. When you run the script using the Ansible command, it will update the inventory dynamically. You can download the script form the below link.
https://raw.githubusercontent.com/ansible/ansible/stable-2.9/contrib/inventory/docker.py