Docker Cookbook


Backing Up a Database Running in a Container | 31



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

1.17 Backing Up a Database Running in a Container | 31


Discussion
Although this recipe uses MySQL, the same techniques are valid for Postgres and
other databases. If you use the 
Postgres
 image from Docker Hub, you can also see in
the 
Dockerfile
 that a volume is created (
VOLUME /var/lib/postgresql/data
).
1.18 Sharing Data in Your Docker Host with Containers
Problem
You have data on your host that you would like to make available in a container.
Solution
Use the 
-v
option of 
docker run
to mount a host volume into a container.
For example, to share the working directory of your host within a 
/cookbook
directory
in a container, do this:
$ ls
data
$ docker run -ti -v "$PWD":/cookbook ubuntu:14.04 /bin/bash
root@11769701f6f7:/# ls /cookbook
data
In this example, you mount the working directory in the host into the 
/cookbook
directory in the container. If you create files or directories within the container, the
changes will be written directly to the host working directory, as shown here:
$ docker run -ti -v "$PWD":/cookbook ubuntu:14.04 /bin/bash
root@44d71a605b5b:/# touch /cookbook/foobar
root@44d71a605b5b:/# exit
exit
$ ls -l foobar
-rw-r--r-- 1 root root 0 Mar 11 11:42 foobar
By default, Docker mounts the volume in read-write mode. If you want to mount it in
read-only mode, you can specify it after the name of the volume, using a colon. For
example, to mount the previous working directory to 
/cookbook
as read-only, you
would use 
-v "$PWD":/cookbook:ro
. You can inspect your mount mapping with the
docker inspect
 command. See 
Recipe 9.1
 for more information about 
inspect
.
$ docker inspect -f {{.Mounts}} 44d71a605b5b
[{ /Users/sebastiengoasguen/Desktop /cookbook true}]

Download 6,31 Mb.

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