unable to login using docker registry on jenkins I have a Jenkinsfile that I need to login to ECR. this is the relevant section

        script {
          docker.withRegistry('https://01234.dkr.ecr.ap-southeast-1.amazonaws.com/', 'awsId'){
            def image = docker.image("01234.dkr.ecr.ap-southeast-1.amazonaws.com/tas/master-server:${env.BUILD_ID}")
            image.push()
          }


But what gets output in the jenkins build is the strange part

$ docker login -u AKIAZWB**********HET -p ******** https://01234.dkr.ecr.ap-southeast-1.amazonaws.com/
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Error response from daemon: login attempt to https://01234.dkr.ecr.ap-southeast-1.amazonaws.com/v2/ failed with status: 401 Unauthorized


I remember if one runs aws ecr get-login the -u is AWS, not the access key of the credentials. So where do I get this wrong?
I think what you are doing wrong is the way you specify the credentialID to be used. 

Instead of 'awsId' try to use 'ecr:ap-southeast-1:awsId'

docker.withRegistry('https://01234.dkr.ecr.ap-southeast-1.amazonaws.com/', 'ecr:ap-southeast-1:awsId') {
    def image = docker.image("01234.dkr.ecr.ap-southeast-1.amazonaws.com/tas/master-server:${env.BUILD_ID}")
    image.push()                                        
}



EDIT: Check the plugin doc