Push an image

Azure DevOps Services

Use Azure Pipelines to push your image to a container registry such as Azure Container Registry, Docker Hub, or Google Container Registry. Azure Container Registry is a managed registry service based on the open-source Docker Registry 2.0.

For a tutorial on building and pushing images to a container registry, see Build and push Docker images to Azure Container Registry.

To learn how to build a container image to deploy with Azure Pipelines, see Build container images to deploy apps.

About the Docker task

You'll use the Docker@2 task to build or push Docker images, login or logout, start or stop containers, or run a Docker command.

The task uses a Docker registry service connection for Azure Container Registry to log in and push to a container registry. The process for creating a Docker registry service connection differs depending on your registry.

The Docker registry service connection stores credentials to the container registry before pushing the image. You can also directly reference service connections in Docker without an additional script task.

Create a Docker service connection

You'll need to follow a different process to create a service connection for Azure Container Registry, Docker Hub, and Google Container Registry.

With the Azure Container Registry option, the subscription (associated with the Microsoft Entra identity of the user signed into Azure DevOps) and container registry within the subscription are used to create the service connection.


This service connection method uses a service principal and not workload identity federation for authentication. To learn how to use workload identity instead with Azure Container Registry, see Manage service connections for Azure Container Registry.

When you create a new pipeline for a repository that contains a Dockerfile, Azure Pipelines will detect Dockerfile in the repository. To start this process, create a new pipeline and select the repository with your Dockerfile.

  1. From the Configure tab, select the Docker - Build and push an image to Azure Container Registry task.

    Screenshot of Build and push Docker images to Azure Container Registry.

  2. Select your Azure Subscription, and then select Continue.

  3. Select your Container registry from the dropdown menu, and then provide an Image Name to your container image.

  4. Select Validate and configure when you are done.

    A screenshot showing how to configure a docker pipeline to build and publish an image to Azure Container Registry.

    As Azure Pipelines creates your pipeline, it will:

    • Create a Docker registry service connection to enable your pipeline to push images to your container registry.

    • Generate an azure-pipelines.yml file, which defines your pipeline.

For a more detailed overview, see Build and Push to Azure Container Registry document.