Build and push a Docker image
VSTS | TFS 2018 | TFS 2017.3
Build and release pipelines are called definitions in TFS 2018 and in older versions. Service connections are called service endpoints in TFS 2018 and in older versions.
This quickstart explains how to set up continuous integration (CI) to build a container image and push it to a Docker registry like Azure Container Registry or Docker Hub. At the end of this topic, you'll be ready to continuously deploy your image to a Kubernetes cluster or an Azure Web App for Containers.
You must already have a CI build such as one of these:
An Azure subscription for pushing your container image to Azure Container Registry. If you don't have one, you can create one for free.
While the simplest way to try this quickstart is to use a VSTS account, you can also use TFS server. With TFS, make sure that you have configured a build agent with Docker installed.
Create an Azure Container Registry
You can use Azure Container Registry to host the Docker image that is published by the CI process. Follow the steps below to create and configure a registry. In later steps, you use VSTS to deploy the image to an Azure Web App for Containers.
Sign into your Azure Account at https://portal.azure.com.
In the Azure Portal, choose New, Containers, then choose Azure Container Registry.
Enter a Registry name, Resource Group, and select a Location.
For Admin user, choose Enable and then choose Create.
Wait for the Azure Container Registry deployment to finish.
Web or config as code
Do you want to define your build process in your web browser or configure it as code in YAML?
Adapt your CI pipeline
Here you'll adapt your CI pipeline so that it builds and pushes your container image.
VSTS | TFS
Navigate to the Builds tab of the Build and Release hub in VSTS or TFS, and then edit your build pipeline. Select Tasks, and then add the following tasks:
Save and queue the build.
A new build is started. You'll see a link to the new build on the top of the page. Click the link to watch the new build as it happens. Verify that the Docker container image is built and pushed to your container registry.
Now your CI process is set up to push a new Docker image to a container registry every time a change is pushed to your application code.