All Products
Search
Document Center

Alibaba Cloud DevOps:Host Docker deployment

Last Updated:May 08, 2025

Docker can be deployed on Alibaba Cloud DevOps Flow. The final deployment objective is sourced from the image build artifacts of pipeline jobs. This topic describes how to use image build artifacts of pipeline jobs to deploy Docker.

Create a Docker deployment pipeline

On the Flow page, click Create Pipeline. In the dialog box that appears, select the Java Test, build image template.高的 (6)

  1. In the Pipeline Source stage, click Add Pipeline Source, select Codeup as the code source type, add a service connection, and then configure parameters such as Code Repository. 高的 (3)

  2. In the Build Image stage, click Build and push images to ACR (Personal Edition). Select an authorized service connection, and specify the Region, Repository, Docker Tag, and Dockerfile. You can click the link to view the Dockerfile of the spring-boot repository for Alibaba Cloud DevOps Flow.

    高的 (4)

Configure a Docker deployment job

In New Stage, click Create Job. In the panel that appears, click the Deploy tab, and select Docker Deploy on VM to create a job. >

高的 (2)

  1. For Docker Deployment, select an existing host group or click New Host Group.高的 (27)

    Note

    You must install Docker on the host in advance.

  2. Configure the Docker deployment script.

    1. If the image that you deploy is from your private repository, you need to provide the logon authorization information. For security purposes, you can use the variable feature provided by Flow. You can add the DOCKER_USERNAME and DOCKER_PASSWORD variables to specify the logon username and password. On the pipeline editing page, choose Variables and Cache > Variables. On the Variables page, click Create Variable.

      高的 (31)

    2. Run the echo ${DOCKER_PASSWORD} | docker login --username ${DOCKER_USERNAME} --password-stdin registry.cn-hangzhou.aliyuncs.com command in the deployment script. In this command, you must specify the image repository based on your project information. Then, run the relevant command to perform operations on the image of your private repository. The following command is included in the deployment script and used to log on to the image repository.

      echo ${DOCKER_PASSWORD} | docker login --username ${DOCKER_USERNAME} --password-stdin registry.cn-hangzhou.aliyuncs.com
  3. Add variables, which are divided into the following types:

    • Upstream output variables: The upstream output artifacts can be the build artifacts of Alibaba Cloud images or custom images. Configure the upstream output variable image.

    • Custom variables: When you run a command, variables are written to machine environment variables. This way, you can directly use the variables. For example, you can add a custom variable named appname to the deployment script, and assign the value flow-example to the variable. The value is used as the container name.高的

    • The following command is a typical command in a deployment script and used to run a Docker container.

      docker run -d --name ${appname} ${image}
  4. Configure a deployment policy to prevent the negative impact of unstable releases on users and ensure stable business delivery.

Run the deployment job and view Docker deployment details

After the pipeline job is run, in the Deploy > Docker Deployment stage, click Deployment Details to view batches and their logs.image