<p>I am trying to deploy a docker image on a kubernetes cluster.</p>
<p>What I want to achieve on the cluster is the same output as I achieve when I run this command locally (The output will be some generated files)</p>
<pre><code>sudo docker run \
  --env ACCEPT_EULA=&quot;I_ACCEPT_THE_EULA&quot; \
  --volume /my-folder:/opt/data \
  --volume /my-folder:/opt/g2 \
  test/installer:3.0.0
</code></pre>
<p>What I have created for the deployment on the kubernetes side is this:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  namespace: default
spec:
  template:
    metadata:
      name: test
      labels:
        app: test
    spec:
      volumes:
        - name: nfs-volume
          nfs:
            # URL for the NFS server
            server: SERVER_HOSTNAME
            path: PATH
      containers:
      - name: test-container
        image: DOCKER_IMAGE
        resources:
          requests:
            memory: &quot;1Gi&quot;
            cpu: &quot;1000m&quot;
          limits:
            memory: &quot;2Gi&quot;
            cpu: &quot;2000m&quot;
        env:
          - name: ACCEPT_EULA
            value: &quot;I_ACCEPT_THE_EULA&quot;
        volumeMounts:
          - name: nfs-volume
            mountPath: /var/nfs
  replicas: 1
  selector:
    matchLabels:
      app: test
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
</code></pre>
<p>The problem that I have is wrt/ to these two arguments, I can not understand how to perform the related actions on the k8 side. Any suggestions ?</p>
<pre><code>--volume /my-folder:/opt/data
--volume /my-folder:/opt/g2
</code></pre>
<p>Currently I get errors like:
cp: cannot create directory '/opt/test': Permission denied</p>

<p>try this:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  namespace: default
spec:
  template:
    metadata:
      name: test
      labels:
        app: test
    spec:
      volumes:
        - name: my-folder
          hostPath:
            path: /my-folder
      containers:
      - name: test-container
        image: test/installer:3.0.0
        resources:
          requests:
            memory: &quot;1Gi&quot;
            cpu: &quot;1000m&quot;
          limits:
            memory: &quot;2Gi&quot;
            cpu: &quot;2000m&quot;
        env:
          - name: ACCEPT_EULA
            value: &quot;I_ACCEPT_THE_EULA&quot;
        volumeMounts:
          - name: nfs-volume
            mountPath: /var/nfs
          - name:  my-folder
            mountPath: /opt/data
          - name:  my-folder
            mountPath: /opt/g2
  replicas: 1
  selector:
    matchLabels:
      app: test
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
</code></pre>
