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 Dockerfile 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 lists the Dockerfile commands supported by Image Builder.
Command Format or example Description
FROM
  • FROM IMAGE:<The ID of the image>
  • FROM IMAGE_FAMILY:<The name of the image family>
Specifies the source image. The commands cannot be used in image components. After you configure the source image in image templates, the system generates a FROM command.
Note If you manually configure a FROM command in image templates, the FROM command overwrites the command generated by the system after you configure a source image.
RESTART RESTART Restart 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 all lines 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 ENV key1="value1" key2="value2".
WORKDIR
  • WORKDIR /<path>
  • WORKDIR <path1>/<path2>
Configures working directories.
COPY
  • COPY {The address of the network file} <<The local directory>
  • COPY <The path of the local file> <The 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 all lines except the last line.
CMD
  • CMD ["executable","param1","param2"]
  • CMD command param1 param2
Boots the instance that is created from the image at startup.
ENTRYPOINT
  • ENTRYPOINT ["executable","param1","param2"]
  • CMD command param1 param2
Boots the instance that is created from the image at startup.