• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. User Guide 2.0
  4. Job Management
  5. Setting Container Startup Command

Setting Container Startup Command

When creating a job, you can specify the processes running in the container using an image.

By default, the image runs the default command. To run a specific command or rewrite default values, specify the following settings:

  • Working directory: Specifies the working directory of the command.
    NOTE:

    If the working directory is not specified in the image or on the console, the default value is /.

  • Running command: Controls the running of an image.
  • Parameters: Parameters transferred to the running command.

Commands and Parameters for Running a Container

The Docker image has metadata that stores image information. If no lifecycle command and parameter is set, CCE runs the default commands and parameters provided during image creation, that is, Docker native commands Entrypoint and CMD. For details, see Entrypoint Description and CMD Description in Docker documentation.

If the commands and parameters used to run a container are set during job creation, the default commands Entrypoint and CMD will be overwritten during image creation. The rules are as follows:

Table 1 Commands and parameters for running a container

Image Entrypoint

Image CMD

Command for Running a Container

Parameter for Running a Container

Command Executed

[touch]

[/root/test]

Not set

Not set

[touch /root/test]

[touch]

[/root/test]

[mkdir]

Not set

[mkdir]

[touch]

[/root/test]

Not set

[/opt/test]

[touch /opt/test]

[touch]

[/root/test]

[mkdir]

[/opt/test]

[mkdir /opt/test]

Setting the Startup Command

  1. Log in to the CCE console. When creating a job, choose Advanced Settings > Lifecycle > Start.
  2. Set the startup command by referring to Table 2 and Table 3.

    NOTE:
    • The current startup command is provided as a string array and corresponds to the ENTRYPOINT startup command of Docker. The format is as follows: ["executable", "param1", "param2",..]. For details about how to start Kubernetes containers, click here.
    • The lifecycle of a container is the same as that of the startup command. That is, the lifecycle of the container ends after the command is executed.
    Table 2 Setting the container startup command (single command)

    Command Mode

    Procedure

    Executable command

    Click Add and enter an executable command, for example, /run/server.

    Parameter

    Click Add and enter command parameters for controlling the running of the container, for example, --port=8080.

    If there are multiple parameters, enter parameters separately in text boxes, as shown in Figure 1.

    Table 3 Setting container startup commands (multi-command)

    Command Mode

    Procedure

    Executable command

    Click Add and enter an executable command, for example, /bin/sh.

    Parameter

    Click Add and enter command parameters for controlling the running of the container.

    If there are multiple parameters, enter parameters separately in text boxes.

    NOTE:

    If there are multiple commands, you are advised to use /bin/sh or other shell commands as the running command and enter other commands as parameters. In this case, executable commands and parameters can be entered in the same text box, as shown in Figure 2.

    Figure 1 Single command
    Figure 2 Multi-command