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
for example: on my local I have the following:
/work-dir tree
├── bootstrap.properties
├── index.html
├── indexing_configuration.xml
├── repository.xml
└── wrapper.sh
init container should run a script wrapper.sh to copy these
files into the mounted volume on app container which is /usr/share/jack-configs/
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.
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.
This docs shows how to do what you want.
An example YAML is the following:
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: {}
To accomplish what you want, you have to change the command
in the init container to execute your script, this bit I leave you try.
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