Docker Cookbook


Sharing Data Between Containers | 33



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

1.19 Sharing Data Between Containers | 33


the host. Docker created it under 
/var/lib/docker/volumes/
. From the host you can
read and write to it. Changes will persist and be available if you restart the container:
$ sudo touch /var/lib/docker/volumes/dbba7caf8d07b862b61b39.../foobar2
$ docker start b5835d2b951e
$ docker exec -ti b5835d2b951e /bin/bash
root@b5835d2b951e:/# ls /cookbook
foobar foobar2
To share this data volume with other containers, use the 
--volumes-from
option. Let’s
start fresh and create a data container, and then start another container that will
mount the volume from this source data container:
$ docker run -v /data --name data ubuntu:14.04
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ docker inspect -f {{.Mounts}} data
[{4ee1d9e3d453e843819c6ff... /var/lib/docker/volumes/4ee1d9e3d453e843819c6ff... \
/_data /data local true]
The data container is not running. Still, the volume mapping exists
and the volume has persisted in 
/var/lib/docker/vfs/dir
. You can
remove the container and the volume only with 
docker rm -v
data
. If you do not use the 
rm -v
option to delete containers and
their volumes, you will end up with lots of orphaned volumes.
Even though the data container is not running, you can mount the volume from it
with the 
--volumes-from
option:
$ docker run -ti --volumes-from data ubuntu:14.04 /bin/bash
root@b94a006377c1:/# touch /data/foobar
root@b94a006377c1:/# exit
exit
$ sudo ls /var/lib/docker/volumes/4ee1d9e3d453e843819c6ff...
foobar
See Also

Understanding
volumes
• Data 
container
• Docker 
volumes
• Official Docker 
documentation
• The aha moment of 
Docker volumes

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   33   34   35   36   37   38   39   40   ...   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