All Products
Search
Document Center

CloudOps Orchestration Service:Docker image deployment

Last Updated:Sep 04, 2026

Deploy applications from Docker images stored in Container Registry (ACR) Personal or Enterprise Edition.

To deploy from a third-party image repository, use a command-only deployment.

How it works

Important
  • If you deploy to an ESS scaling group, scaling activities are paused during the deployment. The activities automatically resume after the deployment is complete, regardless of whether it succeeds or fails.

  • The deployment process first stops the old version and then starts the new one. Each deployment runs the stop script before it runs the start script.

  • The Docker image is automatically pulled to the Elastic Compute Service (ECS) instance during deployment. Do not include an image pull command in the start script.

  1. Create and publish a deployment.

    Specify the application's source file location in OSS, along with the start and stop scripts.

    Create a release task, select a release mode, and publish the deployment to the target application group.

  2. Automated deployment flow.

    1. Retrieves the deployment information. This includes the Docker image details and the application's start and stop scripts.

    2. Pulls the Docker image from the image repository to the ECS instance.

    3. Runs the stop script to stop the old version of the application.

    4. Runs the start script to start the new version of the application.

Usage notes

  • Deployments are supported only on Linux instances.

  • The start and stop scripts must be shell scripts.

Procedure

  1. Prepare the application, group, and ECS instances.

    Before you deploy, create an application and a group in ECS Application Management. Then, add your ECS instances to the group.

    1. If you do not have an ECS instance, go to the ECS console - Custom Launch page to create a Linux ECS instance.

      The following example scripts are for these images. If you use a different image, you must modify the scripts accordingly.
    2. Go to the ECS console - Application management page and click Create from Existing Resources to create an application and an application group, and import the ECS instance into the application group.

    3. Install Docker on the ECS instances in the group. On the O&M tab of the application group, select ACS-ECS-BulkyConfigureOOSPackageWithTemporaryURL to install Docker in a batch.

      If your ECS instance was created from a custom image, you cannot install extensions this way. You must remotely connect to the instance and manually install Docker.
  2. Create a Docker image deployment.

    1. Pull the sample image to your local machine, and then push the image to an ACR Enterprise Edition or ACR Personal Edition repository.

      docker pull aliyun-computenest-opensource-registry.cn-hangzhou.cr.aliyuncs.com/default/aliyun-code-deploy:latest
    2. Go to the ECS console - Application management page. On the My Applications tab, click the name of your target application.

    3. On the application details page, select the Deployment tab, and then click Create Deployment.

    4. On the Create Deployment page, set Deployment Type to Docker Image, and configure the following key fields.

      • ACR instance information: Enter the ACR instance information. After you enter the image version, the system automatically generates an image address. Use this address in the application start script.

        Important

        If you use ACR Personal Edition, configure the username and password for your ACR Personal Edition in the advanced settings of the application details page.

      • Working directory: The execution directory for the application start and stop scripts. Example: /root/deploy.

      • Application start script: Replace <Registry Address> with the actual address.

        ### The Docker image is automatically pulled to the ECS instance during deployment. You can start the container directly.
        ### Start the current version of the container
        start_application() {
          image_name="<Registry Address>"
          container_name="my-container"
          docker run -d -p 8080:8080 --name ${container_name} ${image_name}
        }
        
        start_application
      • Application stop script:

        stop_application() {
          # Query whether the container exists by the container name, and delete the container if it exists
          container_name="my-container"
          container_id=$(docker ps -aq -f name=${container_name}) 
          if [ -n "$container_id" ]; then
            docker rm -f $container_id
          fi
        }
        
        stop_application
    5. After you configure all parameters, click OK to save the deployment.

  3. Go back to the deployment list, find the deployment that you created, and click Deploy. Select the target group and click OK to start the deployment.

  4. Verify the result.

    1. Navigate to the details page of the target instance. Click Connect and select Workbench. Follow the on-screen prompts to access the terminal.

    2. Run the curl http://localhost:8080/hello command. A response of Alibaba Spring Sample! indicates a successful deployment.

Key fields

Field

Description

Container Registry region

The region where the ACR instance is located.

Container Registry instance ID

ACR Enterprise Edition instance ID

Namespace

The namespace where the image repository is located.

Repository name

The name of the image repository.

Image version

The Docker image version to deploy.

Pull image over private network

If selected, the ACR instance and the ECS instance must be in the same Virtual Private Cloud (VPC), and you must configure access control for the VPC.
Otherwise, the image is pulled over the public network. Ensure that both the ECS instance and the ACR instance have public network access enabled.



Working directory

The working directory for the application's start and stop scripts.

  • Enter an absolute path.

  • You can enter a directory that does not exist. It is created automatically during execution.

Application start script

The Shell script used to start the application.

Application stop script

The shell script to stop the application.
The script must correctly stop both the current and previous application versions and exit gracefully if the application is not running.



For example, the following script stops a container named my-container. It assumes all container versions share the same name and does not report an error if the container does not exist:

container_name="my-container"
container_id=$(docker ps -aq -f name=${container_name}) 
if [ -n "$container_id" ]; then
  docker rm -f $container_id
fi