This topic describes the Dockerfile commands supported by Image Builder.

The commands supported by Image Builder are compatible with some Dockerfile commands. If you are familiar with Dockerfile commands, you can quickly get started with Image Builder. If you are not familiar with Dockerfile commands, you can learn about the commands supported by Image Builder from this topic. For more information about Dockerfile commands, such as the difference between CMD and ENTRYPOINT commands, visit Dockerfile reference.

The following table describes the commands supported by Image Builder.
Command Format or example Description
FROM
  • FROM IMAGE:<Image ID>
  • FROM IMAGE_FAMILY:<Image family name>
Specifies the source image. The command is not supported by image components. After you configure a source image in an image template, the system generates a FROM command.
Note If you manually configure a FROM command in an image template, the FROM command overwrites the command generated by the system after you configure a source image.
COMPONENT COMPONENT ic-bp18hy47cqavewsb**** Specifies the image components. You can specify system components or custom components. The command is applicable only to image templates. When you create an image template, you can run the command to specify one or more image components to define the image template in a quick manner.
RESTART RESTART Restarts the instance. Do not add content to the command.
RUN
RUN echo hello;\
echo world;
Builds an image. The command can be separated into multiple lines. A line break (\) must be added to the end of each line except the last line.
ENV
  • ENV key value
  • ENV key1="value1" key2="value2"
Configures system variables. The command is in the form of a key-value pair.
Note Double quotation marks (") must be included in the following command format: ENV key1="value1" key2="value2".
WORKDIR
  • WORKDIR /<path>
  • WORKDIR <path1>/<path2>
Configures working directories.
COPY
  • COPY {Network file address} <Local directory>
  • COPY <Path of the local file> <Local directory>
Copies files.
USER USER <username> Configures users who execute commands.
Note The <username> variable must be set to an existing username in the system. Otherwise, an error is reported when the command is run.
LABEL
LABEL user="username"\
date="2020-11-11" key="value"
Defines template metadata. The command can be separated into multiple lines. A line break (\) must be added to the end of each line except the last line.
CMD
  • CMD ["executable","param1","param2"]
  • CMD command param1 param2
Runs on instance startup.
ENTRYPOINT
  • ENTRYPOINT ["executable","param1","param2"]
  • CMD command param1 param2
Runs on instance startup.