All Products
Search
Document Center

Elastic Compute Service:Command-only deployments

Last Updated:Dec 15, 2025

Use this deployment type to publish an application when no source files are required and the entire deployment is handled by scripts.

How it works

Important
  • If you deploy to an application group that is an Auto Scaling (ESS) group, scaling activities are paused during the deployment. They automatically resume after the deployment finishes, whether it succeeds or fails.

  • The deployment process follows a stop-then-start principle. Each deployment first runs the stop script and then runs the start script.

  1. 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.

  2. Automated deployment flow of the publishing task.

    1. Retrieves the deployment information, including the application's start and stop scripts.

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

    3. 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

  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, 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.
    2. 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.

    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 the deployment.

    1. Pull the sample image to your local machine. Then, push the image to your personal edition ACR 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 the target application.

    3. On the application details page, select the Parameters tab and click Create Parameter. Create username and password parameters to store your ACR Personal Edition credentials. For security, create the password parameter as an encrypted parameter.

    4. On the application product page, select the Deployment tab, and then click Create Deployment.

    5. On the Create Deployment page, set RevisionType to Command-only. Then, set the parameters and click OK.

      • Working Directory: The directory in which the start and stop scripts are executed. For example, /root/deploy.

      • Application Start Script: Replace the <repo> and <image> values with the information for your Personal Edition ACR instance.

        In the figure below, the first field is repo and the second field is image. Use these values for the corresponding parameters in the application start script.image
        ### Start the current version of the application            
        function start_application() {
           repo="<repo>"
           image="<image>"
           container_name="my-container"
           docker login --username=${username} --password=${password} $repo
           docker pull $image
           docker run -d -p 8080:8080 --name $container_name $image
        }
        
        start_application
      • Application Stop Script:

        ### Stop the container (if any)
        
        function stop_application() {
          # Query for the container by name. If it exists, delete it.
          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
  3. 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.

  4. Verify the result.

    1. 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.

    2. Run the curl http://localhost:8080/hello command. A return value of Alibaba Spring Sample! indicates that the deployment was successful.

Important fields

Field

Description

Working directory

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

  • An absolute path is required.

  • A non-existent directory can be specified. 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 the current and previous versions of the application. When no application is running, the script must also exit normally without errors.

For example, the following script stops a container named my-container. This script assumes that every version of the container has the same name. The script 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