The major difference between a container(runtime) and an image(static) is the top writable layer. All writes to the container that add new or modify existing data are stored in this writable layer. When the container is deleted, the writable layer is also deleted. The underlying image layers remain unchanged.
Because each container has its own writable container layer, and all changes are stored in this container layer, multiple containers can share access to the same underlying image and yet have their own data state.
Image layers
Init layer(there is Init layer between image layer and container layer on ubuntu actually) which is system related info like /dev host etc.
Container layer(R/W layer)
Image on disk /var/lib/docker
Let’s see what’s the file layout for image and container. here is the layout for it
Below output is the file layout after create a container(official ubuntu image)
docker/aufs directory
1 2
$ ls /var/lib/docker/aufs diff layers mnt
diff/: content of each layer(image layer and init layer and container layer)
layers/: As layer has relationship, file in it shows all layers it based on
mnt/: As in diff/, it only shows content of each layer, here it shows content of all layers it based on(actually it’s aufs mount point(single dir)).
Note: without container runs, all are empty! when container runs only the contain layer mount point has content!!!