Updated on 2023-09-26 GMT+08:00

Startup Command

Starting the container is to start the main process. However, some preparations must be made before the main process is started. For example, you may configure or initialize MySQL databases before running MySQL servers. You can set ENTRYPOINT or CMD in the Dockerfile when creating an image. As shown in the following, the ENTRYPOINT ["top", "-b"] command is set in the Dockerfile. This command will be executed during container startup.

FROM ubuntu
ENTRYPOINT ["top", "-b"]

When calling an API, you only need to configure the containers.command parameter of the pod. This parameter is of the list type. The first parameter is the execution command, while the subsequent parameters are the command parameters.

apiVersion: v1
kind: Pod
metadata:
  name: Ubuntu
spec:
  containers:
  - image: Ubuntu
    name: container-0
    resources:
      limits:
        cpu: 500m
        memory: 1024Mi
      requests:
        cpu: 500m
        memory: 1024Mi
    command:                     # Startup command
    - top
    - "-b"
  imagePullSecrets:
  - name: imagepull-secret