<p>I have a Google Kubernetes Engine running and I'm trying to deploy a mongo container. Everything works fine except when I try to use the argument &quot;--wiredTigerCacheSizeGB&quot;, then the deployment fails because this command is not recognized. I'm using the latest Mongo version (5.0) and I see nothing in the documentation saying that this should not work.</p>
<p>Here is the yml configuration of the POD creation:</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
spec:
  podManagementPolicy: OrderedReady
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      environment: test
      role: mongo
  serviceName: mongo
  template:
    metadata:
      creationTimestamp: null
      labels:
        environment: test
        role: mongo
      namespace: default
    spec:
      containers:
      - command:
        - mongod
        - --wiredTigerCacheSizeGB 2
        image: mongo:5.0
        imagePullPolicy: Always
        name: mongo
        ports:
        - containerPort: 27017
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /data/db
          name: mongo-persistent-storage
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 10
      tolerations:
      - effect: NoSchedule
        key: dedicated
        operator: Equal
        value: backend
  updateStrategy:
    type: OnDelete
  volumeClaimTemplates:
  - apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      annotations:
        volume.beta.kubernetes.io/storage-class: standard
      creationTimestamp: null
      name: mongo-persistent-storage
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 20Gi
      volumeMode: Filesystem
</code></pre>

Hugo Sartori
<p>Does it work if you remove the <code>--wiredTigerCacheSizeGB</code> flag?</p>
<p><strike>I would be surprised.</strike></p>
<blockquote>
<p>It does appear to work (see below) but I can't explain why. I am surprised!</p>
</blockquote>
<p>If this is the correct <a href="https://github.com/docker-library/mongo/blob/master/5.0/Dockerfile" rel="nofollow noreferrer">Dockerfile</a> for the image, then it uses a Docker <code>CMD</code> to run <code>mongod</code>.</p>
<p>If so, you'd need to run the image on Kubernetes using <code>args</code> not <code>command</code> in order to correctly override the container image's <code>CMD</code> and <strong>not</strong> override the container image's <code>ENTRYPOINT</code>, i.e.</p>
<pre><code>containers:
- name: mongo
  args:
  - mongod
  - --wiredTigerCacheSizeGB=2
</code></pre>
<blockquote>
<p><strong>NOTE</strong> The inclusion of <code>=</code> between the flag and value to avoid introducing YAML parsing issues.</p>
</blockquote>
<p>I tested this hypothesis using <code>podman</code>; you can replace <code>podman</code> with <code>docker</code> in what follows if you use <code>docker</code>:</p>
<pre class="lang-sh prettyprint-override"><code># Does not work: Override `ENTRYPOINT` with mongod+flag
# This is effectively what you're doing
podman run \
--interactive --tty --rm \
--entrypoint=&quot;mongod --wiredTigerCacheSizeGB=2&quot; \
docker.io/mongo:5.0 \
Error: executable file `mongod --wiredTigerCacheSizeGB=2` not found in $PATH:
No such file or directory:
OCI runtime attempted to invoke a command that was not found

# Works: Override `CMD`
# This is what I thought should work
podman run \
--interactive --tty --rm \
docker.io/mongo:5.0 \
  mongod \
  --wiredTigerCacheSizeGB=2

# Works: Override `ENTRYPOINT` w/ mongod
# This is what I thought wouldn't work
podman run \
--interactive --tty --rm \
--entrypoint=mongod \
docker.io/mongo:5.0 \
  --wiredTigerCacheSizeGB=2
</code></pre>
