All Products
Search
Document Center

Elastic Container Instance:Set startup command and arguments

Last Updated:Jun 20, 2026

An Elastic Container Instance (ECI) starts a container using the settings predefined in its image. If you did not set a startup command and arguments when you built the image, or if you want to override the existing ones, you can specify them when creating an ECI instance. This allows you to define the container's startup behavior and initialization process, ensuring it runs correctly and provides the required services. This topic describes how to set the startup command and arguments for a container.

How it works

To override the default startup settings defined in the image, such as the working directory, startup command, and arguments, you can configure the following parameters:

  • Working directory

    When you build an image, you can use the WORKDIR instruction to specify the container's working directory. Commands executed at container startup run in this directory. For more information, see WORKDIR.

    When you create an ECI instance, you can override the WORKDIR instruction by setting the container's working directory (WorkingDir).

    Note
    • If the image does not specify a WORKDIR and you do not set a working directory when creating the ECI instance, the working directory defaults to the root directory (/).

    • If the specified working directory does not exist, the system automatically creates it.

  • Startup command and arguments

    When you build an image, you can use the ENTRYPOINT and CMD instructions to specify the command and arguments to execute when the container starts. For more information, see ENTRYPOINT and CMD.

    When you create an ECI instance, you can override the ENTRYPOINT and CMD instructions by setting the container's startup command (Command) and arguments (Arg). The following rules determine how these overrides take effect:

    Important

    The startup command must be a command supported by the container image. Otherwise, the container fails to start.

    Image ENTRYPOINT

    Image CMD

    Container Command

    Container Arg

    Executed command

    Description

    mkdir

    /data/backup

    Not set

    Not set

    mkdir /data/backup

    If the container's Command and Arg are not set, the image's ENTRYPOINT and CMD are executed.

    mkdir

    /data/backup

    cd

    Not set

    cd

    If the container's Command is set but Arg is not, only the container's Command is executed. The image's ENTRYPOINT and CMD are ignored.

    mkdir

    /data/backup

    Not set

    /opt/backup

    mkdir /opt/backup

    If the container's Arg is set but Command is not, the image's ENTRYPOINT is executed with the container's Arg.

    mkdir

    /data/backup

    cd

    /opt/backup

    cd /opt/backup

    If the container's Command and Arg are both set, only the container's Command and Arg are executed. The image's ENTRYPOINT and CMD are ignored.

Configuration

API

When you call the CreateContainerGroup operation to create an ECI instance, you can set the working directory, startup command, and arguments for a container by using the WorkingDir, Command, and Arg parameters. The following table describes these parameters. For more information, see CreateContainerGroup.

Parameter

Type

Example

Description

Container.N.WorkingDir

String

/usr/local/

The container's working directory.

Container.N.Command.N

Array

sleep

The container's startup command, specified as an array of strings. The array can contain up to 20 elements.

Container.N.Arg.N

Array

100

The arguments for the startup command, specified as an array of strings. The array can contain up to 10 elements.

Console

When you create an ECI instance from the Elastic Container Instance buy page, you can set the startup command and arguments for each container in the Container Configurations section.

容器启动命令