Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker with no volume running, where does container system file store?

Tags:

docker

volume

If I run a container with no volume specified, where does container system file store ?

  • docker run -it c_name i_name:tag

when I run a container without volume, only container folder created in /var/lib/docker/container, but I If I create a large file in container file system, where does it stored on host? Because I want to know if it will cause occupying disk size issue.

like image 507
Kamil Avatar asked Sep 12 '25 16:09

Kamil


1 Answers

The container's storage is composed of different layers, different layers will finally form a merged layer.

Let's make a small experiment next:

1. Start a container & setup a new file:

# docker run -idt --name trial debian /bin/bash
# docker exec -it trial /bin/bash
root@e6c2b6336753:/# echo "helloworld" > test.txt
root@e6c2b6336753:/# cat test.txt
helloworld

2. Find the merged storage layer id:

# docker inspect --format=" {{ .GraphDriver.Data.MergedDir }} " trial
/var/lib/docker/overlay2/8f2e14d33448cb83e581b2950a69faa827a012904051c845abf550273196f90f/merged

Here, 8f2e14d33448cb83e581b2950a69faa827a012904051c845abf550273196f90f is the layer id.

3. Check layer:

# cd /var/lib/docker/overlay2/8f2e14d33448cb83e581b2950a69faa827a012904051c845abf550273196f90f/merged
root@shlava:/var/lib/docker/overlay2/8f2e14d33448cb83e581b2950a69faa827a012904051c845abf550273196f90f/merged# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  test.txt  tmp  usr  var
root@shlava:/var/lib/docker/overlay2/8f2e14d33448cb83e581b2950a69faa827a012904051c845abf550273196f90f/merged# cat test.txt
helloworld

So, as a conclusion, you could see from above, the file system contents could be found in /var/lib/docker/overlay2/ with layer id as folder, you could check the disk there.

like image 117
atline Avatar answered Sep 14 '25 09:09

atline