Docker Cookbook


See Also • Managing data in containers 32 | Chapter 1: Getting Started with Docker



Download 6,31 Mb.
Pdf ko'rish
bet36/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   32   33   34   35   36   37   38   39   ...   260
Bog'liq
Docker Cookbook

See Also

Managing data in containers
32 | Chapter 1: Getting Started with Docker



Understanding volumes
• Data 
container
• Docker 
volumes
1.19 Sharing Data Between Containers
Problem
You know how to mount a host volume into a running container, but you would like
to share a volume defined in a container with other containers. This would have the
benefit of letting Docker manage the volumes and support the principle of single
responsibility.
Solution
Use data containers. In 
Recipe 1.18
, you saw how to mount a host volume into a con‐
tainer. You used the 
-v
option of 
docker run
, specifying a host volume and a path
within a container to mount that volume to. If the host path is omitted, you create a
data container
. The volume specified is created inside the container as a read-write
filesystem not layered on top of the read-only layers used to create the container
image. Docker manages that filesystem, but you can read and write to it from the
host. Let’s illustrate this (with a truncated ID of the volumes for brevity):
$ docker run -ti -v /cookbook ubuntu:14.04 /bin/bash
root@b5835d2b951e:/# touch /cookbook/foobar
root@b5835d2b951e:/# ls cookbook/
foobar
root@b5835d2b951e:/# exit
exit
bash-4.3$ docker inspect -f {{.Mounts}} b5835d2b951e
[{dbba7caf8d07b862b61b39... /var/lib/docker/volumes/dbba7caf8d07b862b61b39... \
/_data /cookbook local true}]
$ sudo ls /var/lib/docker/volumes/dbba7caf8d07b862b61b39...
foobar
The directory created by the Docker engine to store the data in the
volume defined resides on the Docker host. If you are using
Docker Machine to set up a remote Docker host, you will need to
connect to this remote Docker host to see the data path of the
Docker volumes.
When the container is started, Docker creates the 
/cookbook
directory. From within
the container, you can read and write to this directory. Once you exit the container,
you can use 
inspect
(see 
Recipe 9.1
) to know where the volume has been created on

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   32   33   34   35   36   37   38   39   ...   260




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish