Docker run inline command fails – Cannot find file in image Azure Devops pipelines

What I am trying to achieve in the Azure devops pipeline is :
1. Built a image using a task in pipeline
2. In next task trying to run the image in inline script task.
Like this.

- task: [email protected]
        inputs:
          targetType: 'inline'
          script: |
            'docker pull $(acrname)/$(imagename):$(Build.BuildId)'
            'docker run $(acrname)/$(imagename):$(Build.BuildId) '

ERROR GETTING IN THE AZURE DEVOPS PIPELINE OUTPUT :

/home/agentusername/agentname/_work/_temp/5e1df-6303-4e04-83c9-bfb1d3f.sh: line 1: docker pull ***/image:123: No such file or directory

/home/agentusername/agentname/_work/_temp/5e1df-6303-4e04-83c9-bfb1d3f.sh: line 1: docker run ***/image:123: No such file or directory

When logged into the build agent where these commands are running,
I see that —
1. docker images gives list of the images and
2. docker run $(acrname)/$(imagename):$(Build.BuildId) runs the image.

Am I doing something wrong in the pipeline??

Source: StackOverflow