How can I give a containerRegistry
to a DevcontainersCi task in an Azure DevOps YAML Pipeline, like in a Docker@2 task?
Currently pushing from this task fails, apparently due to missing authentication (understandable).
The property containerRegistry
like in the Docker@2 task is not accepted by the DevcontainersCi task task.
Or is there another task which allows me to achieve the same, which is to also get the features from the devcontainer already included?
2
Answers
The DevcontainersCi task is an extension developed by Dev Containers. It doesn’t support the service connection (containerRegistry ).
In the extension introduce, it provides an example which shows logging in to an Azure Container Registry instance, and then building and running the dev container with the devcontainer-build-run action. You can follow the example to provide the authentication.
If you need more help when using the extension, you can create issues here.
Based on the documentation of the "Dev Container Build and Run Task" extension, the
DevcontainersCi@0
task does not provide an input to receive the Docker Registry service connection.To connect with a Docker registry, you must add a step before the
DevcontainersCi@0
task to login the registry at first.If you have an existing Docker Registry service connection set to connect with the target Docker registry, you can use a
Docker@2
task to run thelogin
with the Docker Registry service connection.If you do not have a Docker Registry service connection, you can create one for use. Or as
@Miao Tian-MSFT
suggested, you can use a script task to directly run the "docker login
" command with your username and password.If using the script task to directly run the "
docker login
" command, you need to provide and store your username and password as variables in the pipeline. For the security of your sensitive information, I recommended you use the method#1
that login to the Docker registry with a Docker Registry service connection.