<p>I have the following deployment:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: keycloak
  namespace: dev
  labels:
    app: keycloak
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keycloak
  template:
    metadata:
      labels:
        app: keycloak
    spec:
      imagePullSecrets:
        - name: regcred
      containers:
      - name: keycloak
        image: "hub.svc.databaker.io/service/keycloak:0.1.8"
        imagePullPolicy: "IfNotPresent"
        command:
        - "-Dkeycloak.migration.action=import -Dkeycloak.migration.provider=dir -Dkeycloak.profile.feature.upload_scripts=enabled -Dkeycloak.migration.dir=/opt/jboss/keycloak/import-dir -Dkeycloak.migration.strategy=OVERWRITE_EXISTING"  
</code></pre>

<p>And it can not be deployed. The error message is: </p>

<pre><code>CrashLoopBackOff: back-off 5m0s restarting failed container=keycloak pod=keycloak-86c677456b-tqk6w_dev(6fb23dcc-9fe8-42fb-98d0-619a93f74da1)  
</code></pre>

<p>I guess because of the command. </p>

<p>I would like to run a command analog to docker: </p>

<pre><code>keycloak:
    networks:
      - auth
    image: hub.svc.databaker.io/service/keycloak:0.1.7
    container_name: keycloak
    command:
     - "-Dkeycloak.migration.action=import -Dkeycloak.migration.provider=dir -Dkeycloak.profile.feature.upload_scripts=enabled -Dkeycloak.migration.dir=/opt/jboss/keycloak/import-dir -Dkeycloak.migration.strategy=OVERWRITE_EXISTING"
</code></pre>

<p>How to run a command in K8S deployment?</p>

<p><strong>Update</strong>  </p>

<p>I have changed the deployment to: </p>

<pre><code>spec:
  replicas: 1
  selector:
    matchLabels:
      app: keycloak
  template:
    metadata:
      labels:
        app: keycloak
    spec:
      imagePullSecrets:
        - name: regcred
      containers:
      - name: keycloak
        image: "hub.svc.databaker.io/service/keycloak:0.1.8"
        imagePullPolicy: "IfNotPresent"
        args:
         - "-Dkeycloak.migration.action=import"
         - "-Dkeycloak.migration.provider=dir"
         - "-Dkeycloak.profile.feature.upload_scripts=enabled"
         - "-Dkeycloak.migration.dir=/opt/jboss/keycloak/import-dir"      
         - "-Dkeycloak.migration.strategy=OVERWRITE_EXISTING"
</code></pre>

<p>and receive the error:</p>

<pre><code>RunContainerError: failed to start container "012966e22a00e23a7d1f2d5a12e19f6aa9fcb390293f806e840bc007a733c1b0": Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"-Dkeycloak.migration.action=import -Dkeycloak.migration.provider=dir -Dkeycloak.profile.feature.upload_scripts=enabled -Dkeycloak.migration.dir=/opt/jboss/keycloak/import-dir -Dkeycloak.migration.strategy=OVERWRITE_EXISTING\": stat -Dkeycloak.migration.action=import -Dkeycloak.migration.provider=dir -Dkeycloak.profile.feature.upload_scripts=enabled -Dkeycloak.migration.dir=/opt/jboss/keycloak/import-dir -Dkeycloak.migration.strategy=OVERWRITE_EXISTING: no such file or directory": unknown
</code></pre>

softshipper
<p>If your container has an entrypoint already you can provide the arguments only. This can be done with <code>args</code>. To define or override the entrypoint use <code>command</code>.</p>

<pre><code>keycloak:
    networks:
      - auth
    image: hub.svc.databaker.io/service/keycloak:0.1.7
    container_name: keycloak
    command: ["./standalone.sh"]
    args:
     - "-Dkeycloak.migration.action=import"
     - "-Dkeycloak.migration.provider=dir"
     - "-Dkeycloak.profile.feature.upload_scripts=enabled"
     - "-Dkeycloak.migration.dir=/opt/jboss/keycloak/import-dir"      
     - "-Dkeycloak.migration.strategy=OVERWRITE_EXISTING"

</code></pre>
