The data volume
The data volume is the fundamental building block of data sharing in the Docker environment. Before getting into the details of data sharing, it is imperative to gain a good understanding of the Data Volume concept. Until now, all the files that we created in an image or a container are part and parcel of the Union filesystem. However, the data volume is part of the Docker host filesystem, and it simply gets mounted inside the container.
A data volume can be inscribed in a Docker image using the VOLUME
instruction of the Dockerfile
. Also, it can be prescribed during the launch of a container using the -v
option of the docker run
subcommand. Here, in the following example, the implication of the VOLUME
instruction in the Dockerfile
is illustrated in detail, in the following steps:
Create a very simple
Dockerfile
with the instruction of the base image (ubuntu:14.04
) and the data volume (/MountPointDemo
):FROM ubuntu:14.04 VOLUME /MountPointDemo
Build the image with the name
mount...