<p>I am using a inital container(k8s version:v1.15.2) to initial skywalking(6.5.0) jar file before container startup.But I could not found the file and directory the intial container create,this is my initial container define:</p>

<pre><code>"initContainers": [
      {
        "name": "init-agent",
        "image": "registry.cn-shenzhen.aliyuncs.com/dabai_app_k8s/dabai_fat/skywalking-agent:6.5.0",
        "command": [
          "sh",
          "-c",
          "set -ex;mkdir -p /skywalking/agent;cp -r /opt/skywalking/agent/* /skywalking/agent;"
        ],
        "resources": {},
        "volumeMounts": [
          {
            "name": "agent",
            "mountPath": "/skywalking/agent"
          },
          {
            "name": "default-token-xnrwt",
            "readOnly": true,
            "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
          }
        ],
        "terminationMessagePath": "/dev/termination-log",
        "terminationMessagePolicy": "File",
        "imagePullPolicy": "Always"
      }
    ]
</code></pre>

<p>now the initial container execute success,I am check the log output like this:</p>

<pre><code>~/Library/Mobile Documents/com~apple~CloudDocs/Document/source/dabai/microservice/soa-red-envelope on  develop_jiangxiaoqiang! ⌚ 14:48:26
$ kubectl logs soa-red-envelope-service-85758d88cb-rmtcj -c init-agent
+ mkdir -p /skywalking/agent
+ cp -r /opt/skywalking/agent/activations /opt/skywalking/agent/bootstrap-plugins /opt/skywalking/agent/config /opt/skywalking/agent/logs /opt/skywalking/agent/optional-plugins /opt/skywalking/agent/plugins /opt/skywalking/agent/skywalking-agent.jar /skywalking/agent
</code></pre>

<p>now something I am confusing is where the directory locate? where is the file I am copy? I am login my container and do not find the jar file:</p>

<pre><code>~/Library/Mobile Documents/com~apple~CloudDocs/Document/source/dabai/microservice/soa-red-envelope on  develop_jiangxiaoqiang! ⌚ 14:50:55
$ kubectl exec -it soa-red-envelope-service-85758d88cb-rmtcj /bin/ash
/ # ls
bin    data   dev    etc    home   lib    media  mnt    opt    proc   root   run    sbin   srv    sys    tmp    usr    var
/ # cd /opt/
/opt # ls
data
/opt #
</code></pre>

<p>now I am starting my app to collection metrics data like this:</p>

<pre><code>ENTRYPOINT exec java -Xmx1g -Xms1g -Dapp.id=$APP_ID -javaagent:/skywalking/agent/skywalking-agent.jar -Dskywalking.agent.service_name=soa-red-envelope-service -Dskywalking.collector.backend_service=10.254.35.220:11800 -jar /root/soa-red-envelope-service-1.0.0-SNAPSHOT.jar
</code></pre>

<p>obviously it tell me could not fond the jar file error:</p>

<pre><code>Error occurred during initialization of VM
agent library failed to init: instrument
Error opening zip file or JAR manifest missing : /skywalking/agent/skywalking-agent.jar
</code></pre>

<p>so what should I do to fix this? I already searching from internet bu found no useful way to solve my situation.</p>

<p>So you should go throught this document first</p>

<p><a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/volumes/#hostpath</a></p>

<p>use <code>hostPath</code> as sample</p>

<pre><code>  volumes:
  - name: agent
    hostPath:
      # directory location on host
      path: /agent
      # this field is optional
      type: Directory
</code></pre>

<p>You need reference it for both init container and normal container.</p>
