I want to update the docker container once when the instance is
booting the first time
If you want to have updated docker images then you can put these in your user-data of during launch of the instance.
If you want to update ECS-agent then just put this in the user-data.
docker pull amazon/amazon-ecs-agent:latest
or if you want to update image from ECR then you need to run this but you the instance should have a role to access the ECR.
docker pull account_id.dkr.ecr.us-west-2.amazonaws.com/test:latest
you can find user-data section under
Launch instance -> configure instance -> Advanced Details -> user data

If you want to update to pull image from some private repo add the login command before pulling the image or if you have already the access then just run docker pull image_name
update:
If you want to add these in your AMI by default, you can use cloud.ini.
Here is the answer that you can look or here.