<p>I have tomcat as docker image.
I have 3 xmls/property files to bring up the war in my tomcat
I need to write init container which will </p>

<ol>
<li>have a script [shell or python]</li>
<li>create a volume and mount it to the main container</li>
<li>copy the property files from my local system to the mounted
volume.</li>
<li>then init-container finishes app container starts after this.</li>
</ol>

<p>for example:
on my local I have the following:</p>

<pre><code>/work-dir tree
├── bootstrap.properties
├── index.html
├── indexing_configuration.xml
├── repository.xml
└── wrapper.sh
</code></pre>

<p>init container should run a script wrapper.sh to copy these<br>
files into the mounted volume on app container 
which is <code>/usr/share/jack-configs/</code></p>

<p>You have to create a volume and mount on both containers. On Init container you run the script to copy the files to the mounted volume.</p>

<p>Instead of using a local file, I would suggest you use a blob storage to copy you files over, will make it much more simple.</p>

<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-initialization/" rel="nofollow noreferrer">This</a> docs shows how to do what you want.</p>

<p>An example YAML is the following:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: init-demo
spec:
  containers:
  - name: nginx
    image: nginx
    ports:
    - containerPort: 80
    volumeMounts:
    - name: workdir
      mountPath: /usr/share/nginx/html
  # These containers are run during pod initialization
  initContainers:
  - name: install
    image: busybox
    command:
    - wget
    - "-O"
    - "/work-dir/index.html"
    - http://kubernetes.io
    volumeMounts:
    - name: workdir
      mountPath: "/work-dir"
  dnsPolicy: Default
  volumes:
  - name: workdir
    emptyDir: {}
</code></pre>

<p>To accomplish what you want, you have to change the <code>command</code> in the init container to execute your script, this bit I leave you try.</p>

<p>PS: If you really want to copy from a local(node) filesystem, you need to mount another volume to the init container and copy from one volume to another</p>
