<p>You'll want to look through the Kubernetes <a href="https://kubernetes.io/docs/concepts/storage/volumes/" rel="nofollow noreferrer">Volume documentation</a> to see what options are available.</p>

<p>In particular look into the <a href="https://kubernetes.io/docs/concepts/storage/volumes/#persistentvolumeclaim" rel="nofollow noreferrer">PersistentVolumeClaim</a>.  This allows you to setup a shared data volume for your pods.  Here's an example snippet from a k8s deployment YAML using a volume:</p>

<pre><code>spec:
      containers:
      - image: **yourdbcontainer**
        name: mysql-db
        env:
        - name: example
          value: example_value
        ports:
        - containerPort: 3306
          name: mysql-db
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim
</code></pre>

CC BY-SA 4.0
2019-10-14T14:58:29.143Z
Thank you for your answer. I know about PV and PVC but I am not sure if this works since a PV must be shared between at least 2 pods, the data container and the application and these 2 can be running on different nodes. I think one way is I use an NFS server so 2 pods can share a PV. Another solution that I found and seems interesting is the StorageOS which creates something like an abstraction layer and provides storage for pods regardless of where they are running and this is what I am looking into at the moment.
AVarf
CC BY-SA 4.0
2019-10-14T15:21:58.923Z
@AVarf A PV does not require 2 pods to work.  It is also not dependent upon nodes.  The whole point is that it is cluster wide.  However, if you are going the NFS route check out this guide: https://matthewpalmer.net/kubernetes-app-developer/articles/kubernetes-volumes-example-nfs-persistent-volume.html
Wesley Rolnick
CC BY-SA 4.0
2019-10-14T14:53:23.377Z
2019-10-14T14:53:23.377Z
Wesley Rolnick
<p>I have an application that relies on 4 docker data containers for the data it needs to run some tests. At the moment I have their docker-compose file and their images but I don't have access to the data containers Dockerfile or actual data.</p>

<p>How this application works in docker-compose is as below: The application is called rtsp_server and it loads different volumes from the data containers such as st-andries4(I just wrote one of them).</p>

<p>This is their docker-compose:</p>

<pre><code># The application
rtsp_server:
  image: rtsp_server_image
  volumes_from:
    - rtsp_data_st_andries4:ro
  ports:
    - "8554:8554"
  command: python ./rtsp-server.py /rtsp_data/st-andries-4 st_andries_4

# Data container
rtsp_data_st_andries4:
  image: st_andries_4:1
  volumes:
    - /rtsp_data/st-andries-4
  command: /bin/true
  mem_limit: 10000000000
</code></pre>

<p>I already brought the application, rtsp_server, to Kubernetes and it works fine but I need to also bring the data containers to k8s but I don't know how to do it.</p>

<docker><kubernetes><docker-compose>
How to bring a docker data container to Kubernetes?
AVarf
# How to bring a docker data container to Kubernetes?

(Asked by: username_0 on 2019-10-14)

I have an application that relies on 4 docker data containers for the data it needs to run some tests. At the moment I have their docker-compose file and their images but I don't have access to the data containers Dockerfile or actual data.
How this application works in docker-compose is as below: The application is called rtsp_server and it loads different volumes from the data containers such as st-andries4(I just wrote one of them).
This is their docker-compose:
# The application
rtsp_server:
  image: rtsp_server_image
  volumes_from:
    - rtsp_data_st_andries4:ro
  ports:
    - "8554:8554"
  command: python ./rtsp-server.py /rtsp_data/st-andries-4 st_andries_4

# Data container
rtsp_data_st_andries4:
  image: st_andries_4:1
  volumes:
    - /rtsp_data/st-andries-4
  command: /bin/true
  mem_limit: 10000000000

I already brought the application, rtsp_server, to Kubernetes and it works fine but I need to also bring the data containers to k8s but I don't know how to do it.

**Tags:** docker, kubernetes, docker-compose


---

## 1 answers

### Answer by username_1 on 2019-10-14. Score: 1 | Accepted answer

You'll want to look through the Kubernetes Volume documentation to see what options are available.
In particular look into the PersistentVolumeClaim.  This allows you to setup a shared data volume for your pods.  Here's an example snippet from a k8s deployment YAML using a volume:
spec:
      containers:
      - image: **yourdbcontainer**
        name: mysql-db
        env:
        - name: example
          value: example_value
        ports:
        - containerPort: 3306
          name: mysql-db
        volumeMounts:
        - name: mysql-persistent-storage
          mountPath: /var/lib/mysql
      volumes:
      - name: mysql-persistent-storage
        persistentVolumeClaim:
          claimName: mysql-pv-claim

> **Comments:**
> **username_0**: Thank you for your answer. I know about PV and PVC but I am not sure if this works since a PV must be shared between at least 2 pods, the data container and the application and these 2 can be running on different nodes. I think one way is I use an NFS server so 2 pods can share a PV. Another solution that I found and seems interesting is the StorageOS which creates something like an abstraction layer and provides storage for pods regardless of where they are running and this is what I am looking into at the moment.  
> **username_1**: @username_0 A PV does not require 2 pods to work.  It is also not dependent upon nodes.  The whole point is that it is cluster wide.  However, if you are going the NFS route check out this guide: https://matthewpalmer.net/kubernetes-app-developer/articles/kubernetes-volumes-example-nfs-persistent-volume.html  

---

