Updated on 2024-11-01 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.

In the following Dockerfile, the ENTRYPOINT ["top", "-b"] command will be executed when the container is started.

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