In this lesson, we will use the VOLUME instruction to automatically create a mount point in a Docker image. When a container is created using this image, a volume will be created and mounted to the specified directory.
Step 1: Set up your environment:
mkdirvolumes
cdvolumes
Step 2: Create the Dockerfile:
viDockerfile
Step 3: Build an Nginx image that uses a volume:
FROMnginx:latestVOLUME ["/usr/share/nginx/html/"]
Step 4: Build the new image:
dockerimagebuild-tnishanthkp/nginx:v1.
Step 5: Create a new container using the nishanthkp/nginx:v1 image: