Authenticate ECR via Docker Remote API

I need to login to my AWS ECR repository so it can pull whatever images it needs by using API. I need to translate what aws ecr get-login --no-include-email --registry-ids <registry_id> command does using Docker Remote API.

For example –

[Solved] API call needs to be made to AWS in order to get login credentials for docker
- API call for this will give me base64encoded string which has username and password
How to use those AWS creds in a docker login API (by using Docker Remote API) call??
- equivalent to docker login -u AWS -p <password> <server_address>)??

I’m tried to make some cURL requests for the Docker Login. Now I’m blue in the face but this request doesn’t give me any response. Please show me where I’m wrong. :frowning:

curl --unix-socket /var/run/docker.sock -d
'{
"username":"AWS",
"serveraddress":"https://<registry_id>.dkr.ecr.us-west-2.amazonaws.com",
"password": "<password_from_above_response>"
}'
-X POST http:/v1.37/auth
curl --unix-socket /var/run/docker.sock -d
'{
"username":"AWS",
"serveraddress":"https://<registry_id>.dkr.ecr.us-west-2.amazonaws.com",
"password": "<password_from_above_response>"
}'
-X POST http:/v1.24/auth
curl --unix-socket /var/run/docker.sock -d
'{
"username":"AWS",
"serveraddress":"https://<registry_id>.dkr.ecr.us-west-2.amazonaws.com",
"password": "<password_from_above_response>"
}'
-X POST http:/localhost/auth
curl --unix-socket /var/run/docker.sock -d
'{
"username":"AWS",
"serveraddress":"https://<registry_id>.dkr.ecr.us-west-2.amazonaws.com",
"password": "<password_from_above_response>"
}'
-X POST http/auth
curl --unix-socket /var/run/docker.sock  -H "Content-Type: application/json" -d
'{
"username":"AWS",
"serveraddress":"https://<registry_id>.dkr.ecr.us-west-2.amazonaws.com",
"password": "<password_from_above_response>"
}'
-X POST http/auth