<p>Some Dockerfile have a <a href="https://docs.docker.com/engine/reference/builder/#volume" rel="nofollow noreferrer">VOLUME</a> command.</p>
<p>What happens when such containers are deployed in Kubernetes, but no kubernetes volume are provided: no persistent volume (PV), nor persistent volume claim (PVC) ?</p>
<p>Where are the file stored ?</p>
<p>Is the volume persistent ?</p>
<hr />
<p>For exemple, Dockerfile image for Docker's <a href="https://github.com/docker-library/postgres/blob/master/13/Dockerfile" rel="nofollow noreferrer">library/postgreSQL</a> container image has:</p>
<pre><code>    VOLUME /var/lib/postgresql/data
</code></pre>
<p>The <a href="https://github.com/helm/charts/blob/master/stable/postgresql/templates/statefulset.yaml" rel="nofollow noreferrer">stable/postgresql</a> helm charts won't always create a PV:</p>
<pre class="lang-yaml prettyprint-override"><code>kind: StatefulSet
### SNIP SNIP ###
      containers:
        - name: {{ template &quot;postgresql.fullname&quot; . }}
          image: {{ template &quot;postgresql.image&quot; . }}
### SNIP SNIP ###
          volumeMounts:
            {{ if .Values.persistence.enabled }}
            - name: data
              mountPath: {{ .Values.persistence.mountPath }}
              subPath: {{ .Values.persistence.subPath }}
{{- end }}
### SNIP SNIP ###
{{- if and .Values.persistence.enabled .Values.persistence.existingClaim }}
        - name: data
          persistentVolumeClaim:
{{- with .Values.persistence.existingClaim }}
            claimName: {{ tpl . $ }}
{{- end }}
{{- else if not .Values.persistence.enabled }}
        - name: data
          emptyDir: {}
{{- else if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
  volumeClaimTemplates:
    - metadata:
        name: data
      {{- with .Values.persistence.annotations }}
        annotations:
        {{- range $key, $value := . }}
          {{ $key }}: {{ $value }}
        {{- end }}
      {{- end }}
      spec:
        accessModes:
        {{- range .Values.persistence.accessModes }}
          - {{ . | quote }}
        {{- end }}
        resources:
          requests:
            storage: {{ .Values.persistence.size | quote }}
        {{ include &quot;postgresql.storageClass&quot; . }}
{{- end }}
</code></pre>

Franklin Piat
<p>(answer based on what I observed with Rancher 2.4, kubernetes 1.17 using Docker)</p>
<p><strong>Short answer</strong>:</p>
<p>a Docker volume is created in <code>/var/lib/docker/volumes/...</code> and removed when the pods is stopped or redeployed.</p>
<p><strong>Long answer</strong>:</p>
<p>Kubernetes doesn't seems to have any knowledge of the volume the containers / in the Dockerfile. No Kubernetes objects seems to be created.</p>
<p>When Kubernetes tell Docker daemon to start a container, Docker creates a volume (like <code>docker volume create</code>) and attach the created volume (unless kubernete's provides a volume to mount).</p>
<blockquote>
<p>Where are the file stored ?</p>
</blockquote>
<p>The file is a regular Docker volume (see <code>docker volume</code> below)</p>
<blockquote>
<p>Is the volume persistent ?</p>
</blockquote>
<p>No, the docker volume is removed when the pod is removed (like if you ran <code>docker rm $mycontainer --volumes</code>)</p>
<hr />
<pre class="lang-sh prettyprint-override"><code>    docker inspect 6ce5f52186d4 | grep '&quot;Driver&quot;: &quot;local&quot;' -A5 -B5
</code></pre>
<pre class="lang-json prettyprint-override"><code>            {
                &quot;Type&quot;: &quot;volume&quot;,
                &quot;Name&quot;: &quot;679135a23430ceea6adb8d89e04c6baf9da33239a83ecb4c4ec3263e2c925d39&quot;,
                &quot;Source&quot;: &quot;/var/lib/docker/volumes/679135a23430ceea6adb8d89e04c6baf9da33239a83ecb4c4ec3263e2c925d39/_data&quot;,
                &quot;Destination&quot;: &quot;/var/lib/postgresql/data&quot;,
                &quot;Driver&quot;: &quot;local&quot;,
                &quot;Mode&quot;: &quot;&quot;,
                &quot;RW&quot;: true,
                &quot;Propagation&quot;: &quot;&quot;
            }
</code></pre>
<pre class="lang-sh prettyprint-override"><code> $ docker volume ls
DRIVER              VOLUME NAME
local               679135a23430ceea6adb8d89e04c6baf9da33239a83ecb4c4ec3263e2c925d39
</code></pre>
<pre class="lang-sh prettyprint-override"><code> $ du -hs /var/lib/docker/volumes/679135a23430ceea6adb8d89e04c6baf9da33239a83ecb4c4ec3263e2c925d39/
51.4M   /var/lib/docker/volumes/679135a23430ceea6adb8d89e04c6baf9da33239a83ecb4c4ec3263e2c925d39/
</code></pre>
