First you should have AWS config on your system.
Pre-requisite : aws-cli should be present on your system. Please use below command to check version of it.
aws --versionOutput :
aws-cli/2.3.1 Python/3.9.10 Darwin/20.6.0 source/arm64 prompt/off
Step 1 : Open terminal and write the following command.
aws configureAWS Access Key ID [****************S4D]:AWS Secret Access Key [****************3bk]: Default region name [eu-west-1]: eu-west-1Default output format [None]: *press enter only, no need of input*
Step 2 : Now, To use with the Docker CLI, pipe the output of the get-login-password command to the docker login command. When retrieving the password, ensure that you specify the same Region that your Amazon ECR registry exists in.
aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 486********.dkr.ecr.eu-west-1.amazonaws.com
Step 3: To pull docker image, go to your jenkins console to check docker image id.
docker pull imageId
e.g. docker pull 486********.dkr.ecr.eu-west-1.amazonaws.com/serviceName:dev-serviceName-65