The problem
You are using Microsoft Azure DevOps. You want to create a CI pipeline that uses Docker for building your great piece of software. Simple. Just create a container registry… You have no access rights. Ask manager. He has no idea how to use Azure Shell Cloud. And also has no access rights. Ask IT. They tell you to wait. Waiting takes time and if you don’t have it here is a quick solution.
The solution
It is not perfect as you need to use your own VSTS agent but setting up one is not so hard and probably you or someone in our team has enough access rights to do it. To have a local docker registry just spin a registry container:
docker run -d -p 5000:5000 --name registry registry:2
Now you can use it in your VSTS pipeline like this:
# triggers parameters etc.
pool: '<your_agent_pool>'
variables:
imageName: 'localhost:5000/my_image'
jobs:
- job: prepare
steps:
- bash: |
echo "Build docker image"
export DOCKER_BUILDKIT=1
docker build --ssh default -t $(imageName) -f docker/Dockerfile .
docker push $(imageName)
- job: build
dependsOn: prepare
container:
image: $(imageName)
steps:
- steps to build your application
# rest of the pipeline
The created image will be pushed to the local registry and pulled in the build stage. Now you can enjoy your pipeline while your IT department is working hard to process your ticket (at the moment of writing this article I am waiting second month already). Good luck. Stay strong. And switch to GitLab.