<p>I am new to docker and Kubernetes, I am trying to create a container having <code>tomcat7/Java7</code> so that I could deploy my <code>webapps</code> into it. The only concern I have are the <code>tomcat/conf</code> config files, which have details of <code>database connections</code>, <code>threadpool</code>, <code>Java Memory</code> etc.</p>

<p>What I want is to copy these files from Kubernetes server to docker-container and place them at right places, while starting the container.</p>

<p>P.S: I don't want to do it via enviroment variables, as they are going to be huge in numbers if I keep a variable for every entry in config files.</p>

<p>You could add a ConfigMap in your Kubernetes, from your tomcat config (files or a whole dir)</p>

<pre><code>kubectl -n staging create configmap special-config --from-file={path-to-tomcat-conf}/server.xml
</code></pre>

<p>And then mount it on your pod (kubectl create -f path/to/the/pod.yaml)</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
 name: tomcat-test-pod
spec:
 containers:
 - name: test-container
   image: tomcat:7.0
   command: [ "catalina.sh", "run" ]
   volumeMounts:
   - name: config-volume
     mountPath: /usr/local/tomcat/conf/server.xml
 volumes:
 - name: config-volume
   configMap:
    # Provide the name of the ConfigMap containing the files you want
    # to add to the container
    name: special-config
</code></pre>

<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-specific-path-in-the-volume" rel="noreferrer">Kubernetes docs</a></p>
