Pulling image from Amazon ECR from Bitbucket Pipelines

I’m trying to pull a docker image from private Amazon Docker repository (ECR) from Bitbucket pipelines.

I’m doing the following:

   - aws ecr get-login --registry-ids $AWS_ID --no-include-email --region $AWS_REGION
   - docker run -d -p 9092:9092 --name=kapi $AWS_ID.dkr.ecr.$AWS_REGION.amazonaws.com/company/kapi:1.0

The error I see on Pipelines:

docker: Error response from daemon: Get https://$AWS_ID.dkr.ecr.$AWS_REGION.amazonaws.com/v2/company/kapi/manifests/1.0: no basic auth credentials.

Source: StackOverflow