How to pass docker run flags via kubernetes pod

You are on the right track. It's just that you also need to include the name of the binary in the command array as the first element. You can find that out by looking​ in the respective Dockerfile (CMD and/or ENTRYPOINT).

In this case: command: ["Mailhog", "-auth-file", "/data/mailhog/auth.file"]


In kubernetes, command is equivalent of ENTRYPOINT. In your case, args should be used.

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#container-v1-core


thanks to @lang2

here is my deployment.yaml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: mailhog
spec:
  replicas: 1
  revisionHistoryLimit: 1
  strategy:
      type: RollingUpdate
  template:
    metadata:
      labels:
        app: mailhog
    spec:
      volumes:
      - name: secrets-volume
        secret:
            secretName: mailhog-login
      containers:
      - name: mailhog
        image: us.gcr.io/com/mailhog:1.0.0
        resources:
          limits:
            cpu: 70m
            memory: 30Mi
          requests:
            cpu: 50m
            memory: 20Mi
        volumeMounts:
        - name: secrets-volume
          mountPath: /data/mailhog
          readOnly: true
        ports:
        - containerPort: 8025
        - containerPort: 1025
        args:
          - "-auth-file=/data/mailhog/auth.file"