title: OpenShift copy files to PVC from container
body: <p>I have a weird issue and I am running out of ideas. I have an OpenShift deployment but unfortunately I don't hava RBAC access so any rsync and other goodies are not fine for me. Let's sum up... I have a storage created which is shared between 2 applications with path /usr/local/tomcat/fop and I have a build based on image. The image used for the build is previously build as binary build locally on my machine and in its Dockerfile I am adding several files there like:</p>
  
  <pre><code>COPY fop.xconf /usr/local/tomcat/fop/conf/fop.xconf
  COPY ExperianPDF2016.gif /usr/local/tomcat/fop/img/
  COPY PDF_Transformation.xslt /usr/local/tomcat/fop/transformation/
  
  RUN [ -d /usr/local/tomcat/fop/xml ] || mkdir -p /usr/local/tomcat/fop/xml
  RUN [ -d /usr/local/tomcat/fop/reports ] || mkdir -p /usr/local/tomcat/fop/reports
  RUN [ -d /usr/local/tomcat/fop/output ] || mkdir -p /usr/local/tomcat/fop/output
  </code></pre>
  
  <p>So what happens here if I deploy the image without adding storage - it is fine, all files are there but I don't have permission the read/write files and also this won't be shared with the other application. However if I map storage and say that I have mount path of /usr/local/tomcat/fop then I have the folder and it's shared between the apps but it is empty, nothing from the image has gone there. </p>
  
  <p>In our DEV environment I used oc rsync to add the missing files in the folder but in the next environment I don't have RBAC permission and I don't have 'Terminal' access nor rsync.</p>
  
  <p>Any directions for solving this would be much appreciated.</p>
  
  <p>[UPDATE]</p>
  
  <p>As I was advised I can use the Init container approach. Here is my deploy config:</p>
  
  <pre><code>spec:
    containers:
      - image: &gt;-
          docker-registry.default.svc:5000/ob-orc-dev/pdf-maker@sha256:a4eadb602e4afb5bf25cc17b916b848cecc06a05d1cd69000cd84feb70df63bd
        imagePullPolicy: Always
        name: bat-dancho
        ports:
          - containerPort: 8080
            protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
          - mountPath: /usr/local/tomcat/fop123
            name: pdf-tst
            subPath: xml
    dnsPolicy: ClusterFirst
    initContainers:
      - command:
          - /bin/sh
          - '-c'
          - cp -R ~/usr/local/tomcat/fop/* ~/usr/local/tomcat/fop123
        image: &gt;-
          docker-registry.default.svc:5000/ob-orc-dev/pdf-maker@sha256:a4eadb602e4afb5bf25cc17b916b848cecc06a05d1cd69000cd84feb70df63bd
        imagePullPolicy: Always
        name: init-myservice
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
          - mountPath: /usr/local/tomcat/fop123
            name: pdf-tst
            subPath: xml
  </code></pre>