I am running a Docker task 'buildAndPush'in Azure Pipeline yaml file, to build my repository image and push to ACR. This work perfectly fine and i could see my image in docker and ACR.
However, I want to break this task. I want to build the image in docker. I want to run the docker image locally once, then run the test script in the docker image (a python file). Only after the test results are successful, I should be pushing this to ACR.
So I started with the build task.
- task: Docker@2
inputs:
containerRegistry: 'mycontainerRegistry'
repository: 'myrepository'
command: 'build'
Dockerfile: '**/Dockerfile'
tags: $(Build.BuildId)
This successfully builds my image. Now I run a bash command to list my images.
- bash: docker image ls
I could see my image built but it shows as '***/myrepository' . This is where the problem lies.
I want to use this image and run my newly built docker image to ensure the run completes successfully
- bash: docker run 'myrepository:$(Build.BuildId)'
I get the error that repo not found. The Build id is correct as I see it in the images tag. I cannot use docker run ***/myrepository:$(Build.BuildId) as it throws an error incorrect format.
[error]invalid argument "***/myrepository:7167" for "-t, --tag" flag: invalid reference format
Is there a way to resolve this. Is this the right approach I am following?
Thanks for your time!
***
isn't a masked secret? – Daniel Mann