Book Image

Learning Docker

By : Pethuru Raj, Jeeva S. Chelladhurai, Vinod Singh, Vinod kumar Singh, Jeeva Chelladhurai, Pethuru Raj Chelliah
Book Image

Learning Docker

By: Pethuru Raj, Jeeva S. Chelladhurai, Vinod Singh, Vinod kumar Singh, Jeeva Chelladhurai, Pethuru Raj Chelliah

Overview of this book

Table of Contents (18 chapters)
Learning Docker
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Sharing host data


Earlier, we described the steps towards creating a data volume in a Docker image using the VOLUME instruction in the Dockerfile. However, Docker does not provide any mechanism to mount the host directory or file during the build time in order to ensure the Docker images are portable. The only provision Docker provides is to mount the host directory or file to a container's data volume during the container's launch time. Docker exposes the host directory or file mounting facility through the -v option of the docker run subcommand. The –v option has three different formats enumerated as follows:

  1. -v <container mount path>

  2. -v <host path>/<container mount path>

  3. -v <host path>/<container mount path>:<read write mode>

The <host path> is an absolute path in the Docker host, <container mount path> is an absolute path in the container filesystem, and <read write mode> can be either read-only (ro) or read-write (rw) mode. The...