Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Docker

You're reading from   Learning Docker Optimize the power of Docker to run your applications quickly and easily

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781784397937
Length 240 pages
Edition 1st Edition
Tools
Arrow right icon
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with Docker 2. Handling Docker Containers FREE CHAPTER 3. Building Images 4. Publishing Images 5. Running Your Private Docker Infrastructure 6. Running Services in a Container 7. Sharing Data with Containers 8. Orchestrating Containers 9. Testing with Docker 10. Debugging Containers 11. Securing Docker Containers 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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime