Use this deployment type to publish applications from Docker images stored in an Enterprise Edition instance of Container Registry (ACR).
To deploy from a Personal Edition of ACR or a third-party image repository, use a command-only deployment.
How it works
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.
Create and publish the deployment.
Configure the application source file, start script, and stop script for the deployment.
Create a release task, select a release mode, and publish the deployment to the target application group.
Automated deployment flow.
Retrieves the deployment information. This includes the Docker image details and the application's start and stop scripts.
Pulls the Docker image from the image repository to the ECS instance.
Runs the stop script to stop the old version of the application.
Runs the start script to start the new version of the application.
Scope
Deployments are supported only on Linux instances.
The start and stop scripts must be Shell scripts.
Procedure
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.
If you do not have an ECS instance, create one that runs a Linux operating system from the ECS console - Custom Launch page.
We recommend using an ECS image of Alibaba Cloud Linux 3.2104 LTS 64-bit or Ubuntu 22.04 64-bit. The scripts in the following examples are based on these two images. If you use a different image, modify the scripts as needed.
Go to the ECS console - Application Management page, click Create from Existing Resources, create an application and an application group, and import the ECS instance into the application group.
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.
Create a Docker image deployment.
Pull the sample image to your local machine. Then, push the image to your ACR Enterprise Edition instance repository.
docker pull aliyun-computenest-opensource-registry.cn-hangzhou.cr.aliyuncs.com/default/aliyun-code-deploy:latestGo to the ECS console - Application Management page. On the My Applications tab, click the name of the target application.
On the application product page, select the Deployment tab, and then click Create Deployment.
On the Create Deployment page, set RevisionType to Docker Image, and configure the following key parameters.
ACR instance information: Enter the details for your ACR Enterprise Edition instance. After you enter the image version, the system automatically generates a Registry Address. Use this address in the application start script.

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 function start_application() { image_name="<Registry Address>" container_name="my-container" docker run -d -p 8080:8080 --name ${container_name} ${image_name} } start_applicationfunction 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
After you configure all parameters, click OK to save the deployment.
Return to the deployment list. Find the deployment that you created and click Publish. Select the target group and click OK to start the deployment.
Verify the result.
Go to the details page of the target instance. Click Connect and select Workbench. Follow the prompts on the page to log on to the terminal.
Run the
curl http://localhost:8080/hellocommand. A return value ofAlibaba Spring Sample!indicates that the deployment was successful.
Key fields
Field | Description |
Container Registry region | The region where the ACR Enterprise Edition 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 version of the Docker image to be deployed. |
Pull image over private network | If you choose to pull the image over the private network, make sure the ACR instance and the ECS instance are in the same virtual private cloud (VPC). You must also have configured access control for the VPC. |
Working directory | The working directory for the application's start and stop scripts.
|
Application start script | The Shell script used to start the application. |
Application stop script | The Shell script to stop the application. For example, the following script stops a container named |