<p>I'm trying to deploy RabbitMQ on the Kubernetes cluster and using the initcontainer to copy a file from ConfigMap. However, the file is not copying after POD is in a running state. </p>

<p>Initially, I have tried without using an initcontainer, but I was getting an error like "touch: cannot touch '/etc/rabbitmq/rabbitmq.conf': Read-only file system."</p>

<pre><code>kind: Deployment
metadata:
  name: broker01
  namespace: s2sdocker
  labels:
    app: broker01
spec:
  replicas: 1
  selector:
    matchLabels:
      app: broker01
  template:
   metadata:
     name: broker01
     labels:
       app: broker01
   spec:
     initContainers:
      - name: configmap-copy
        image: busybox
        command: ['/bin/sh', '-c', 'cp /etc/rabbitmq/files/definitions.json /etc/rabbitmq/']
        volumeMounts:
          - name: broker01-definitions
            mountPath: /etc/rabbitmq/files
          - name: pre-install
            mountPath: /etc/rabbitmq

     containers:
      - name: broker01
        image: rabbitmq:3.7.17-management
        envFrom:
          - configMapRef:
              name: broker01-rabbitmqenv-cm
        ports:
        volumeMounts:
          - name: broker01-data
            mountPath: /var/lib/rabbitmq
          - name: broker01-log
            mountPath: /var/log/rabbitmq/log
          - name: broker01-definitions
            mountPath: /etc/rabbitmq/files
     volumes:
       - name: pre-install
         emptyDir: {}
       - name: broker01-data
         persistentVolumeClaim:
           claimName: broker01-data-pvc
       - name: broker01-log
         persistentVolumeClaim:
           claimName: broker01-log-pvc
       - name: broker01-definitions
         configMap:
            name: broker01-definitions-cm

</code></pre>

<p>The file "definitions.json" should be copied to /etc/reabbitmq folder. I have followed "<a href="https://stackoverflow.com/questions/49614034/kubernetes-deployment-read-only-filesystem-error">Kubernetes deployment read-only filesystem error</a>". But issue did not fix.</p>

ratnakar
<p>After making changes in the "containers volumeMount section," I was able to copy the file on to /etc/rabbitmq folder. </p>

<p>Please find a modified code here. </p>

<pre><code>      - name: broker01
        image: rabbitmq:3.7.17-management
        envFrom:
          - configMapRef:
              name: broker01-rabbitmqenv-cm
        ports:
        volumeMounts:
          - name: broker01-data
            mountPath: /var/lib/rabbitmq
          - name: broker01-log
            mountPath: /var/log/rabbitmq/log
          - name: pre-install
            mountPath: /etc/rabbitmq
</code></pre>
