All Products
Search
Document Center

Set container commands

Last Updated: Aug 15, 2019

A container group starts the containers using predefined parameters in the container image. To override these default parameters, use the following settings:

  • Working Directory: specifies the working directory.
  • Commands: specifies a list of startup commands.
  • Arguments: specifies a list of startup parameters.

Working Directory

When you create an image, you can configure [WORKDIR] (https://docs.docker.com/engine/reference/builder/#workdir “WORKDIR”) to specify the working directory of a container when it starts. You can override this by using the Working Directory parameter.

Note : If the WORKDIR value is not specified during image creation and the Working Directory value is not set during container group creation, / is used as the default working directory. If the specified directory does not exist, it is created automatically.

Command and Arguments

If you specified the Command and Argument values, the parameters ENTRYPOINT and CMD specified during image creation will be overridden respectively. The following table details how this works:

ENTRYPOINT CMD Command Arguments Executed Description
[mkdir] [/data/backup] Not defined Not defined [mkdir /data/backup] No value defined for Command and Arguments. Default parameter values in the image are used.
[mkdir] [/data/backup] [cd] Not defined [cd /data/backup] Command is defined but Arguments is not. The value of Command takes precedence over CMD in the image.
[mkdir] [/data/backup] Not defined [/opt/backup] [mkdir /opt/backup] Command is not defined but Arguments is. Values of ENTRYPOINT and Arguments are used.
[mkdir] [/data/backup] [cd] [/opt/backup] [cd /opt/backup] Command and Arguments are both defined. Values of Command and Arguments are used.

Note: The values of Command and Arguments must be supported by the container. Otherwise, the container fails to start.