<p>I am using this <a href="https://github.com/keycloak/keycloak-containers/blob/master/server/README.md" rel="nofollow noreferrer">keycloak image</a> and trying to find out how I can copy the oracle jdbc driver into the keycloak container.</p>
<p>There are examples using Init Container to create a file but I will need to copy an existing file.
I know where the jdbc file should be copied to, that's in the documentation for the keycloak image file.
What I don't know is where I should get the jdbc file from. Should it be on a disk somewhere in the cluster or should I download it?</p>

Martin Andersen
<p>Based on this <a href="https://github.com/keycloak/keycloak-containers/blob/master/docker-compose-examples/keycloak-oracle.yml" rel="nofollow noreferrer">example</a>, you should put the driver to the directory <code>/opt/jboss/keycloak/modules/system/layers/base/com/oracle/jdbc/main/driver</code>. The driver JAR must be renamed to <code>ojdbc.jar</code>.</p>
<p>If you want to use <code>initContainers</code> for that, you need to create a volume shared between the init-container and the actual keycloak container, download the driver there and mount it to the appropriate path. More or less something like this:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: keycloak
spec:
  selector:
    matchLabels:
      app: keycloak
  replicas: 1
  template:
    metadata:
      labels:
        app: keycloak
    spec:
      containers:
        - name: keycloak
          image: jboss/keycloak
          volumeMounts:
            - mountPath: /opt/jboss/keycloak/modules/system/layers/base/com/oracle/jdbc/main/driver
              name: driver
          env:
            - name: DB_VENDOR
              value: ORACLE
      initContainers:
        - name: init
          image: alpine
          command: ['sh', '-c', 'wget -o /driver/odbc.jar DRIVER_URL']
          volumeMounts:
            - mountPath: /driver
              name: driver
      volumes:
        - name: driver
</code></pre>
<blockquote>
<p>Replace <code>DRIVER_URL</code> in the command with the actual driver URL</p>
</blockquote>
