A cikin Docker yanayi, sarrafa bayanai yana da mahimmanci don tabbatar da daidaito da ingantaccen adana bayanai. Anan ga cikakken jagora kan yadda ake adanawa da raba bayanai a cikin Docker:
Amfani Data Volumes
Data volumes
sanannen hanya ce don adana bayanai a cikin Docker, ƙirƙirar wurare daban-daban da masu zaman kansu don adanacontainer
bayanai.- Yi amfani da
--volume
ko-v
zaɓi don ƙirƙira da haɗa ƙarar bayanai zuwacontainer
. Misali,docker run -v mydata:/data
yana ƙirƙira ƙarar bayanai mai sunamydata
kuma ya haɗa shi zuwa ga/data
directory a cikincontainer
. Data volumes
za a iya raba tsakanincontainer
, ba su damar samun dama da sabunta bayanan da aka raba.
Hannun Rarraba Host
Injin
- Hakanan zaka iya raba kundayen adireshi daga na'ura mai masaukin baki tare
container
da ta amfani da--volume
ko-v
zaɓi tare da cikakkiyar hanya akan na'ura mai masaukin baki. - Misali,
docker run -v /path/on/host:/path/in/container
raba/path/on/host
kundin adireshi akan na'ura mai masaukin baki tare da/path/in/container
kundin adireshi a cikincontainer
. Duk wani sabuntawa ga kundin adireshi da aka raba yana nunawa nan da nan a cikincontainer
.
Amfani Data Volume Containers
Data volume containers
an sadaukar da sucontainers
don adanawa da raba bayanai. An halicce su don sarrafa su kawaidata volumes
.- Ƙirƙirar ƙarar bayanai
container
ta amfani dadocker create
umarnin kuma haɗa shi zuwa wanicontainers
ta amfani da--volumes-from
zaɓi. - Wannan yana ba da damar raba bayanai cikin sauƙi tsakanin
containers
kuma yana guje wa kwafin bayanai a cikin mutum ɗayacontainers
.
Amfani Bind Mounts
Bind mounts
ba da damar raba kai tsaye na kundayen adireshi na injin runduna tare dacontainers
ba tare da amfani da kundin bayanai ba.- Yi amfani da
--mount
ko-v
zaɓi tare da cikakkiyar hanya akan na'ura mai ɗaukar hoto don ɗaure kundin adireshi. - Misali,
docker run --mount type=bind,source=/path/on/host,target=/path/in/container
ɗaure yana ɗaure/path/on/host
kundin adireshi akan na'ura mai masaukin baki zuwa ga/path/in/container
directory a cikincontainer
. Canje-canje ga kundin adireshi ana nunawa nan da nan a cikincontainer
.
Amfani Docker Volume Plugins
- Docker yana goyan bayan
volume plugin
kari don ajiya da sarrafa bayanai akan dandamali daban-daban. - Plugins kamar
RexRay
,Flocker
, koGlusterFS
samar da ƙima da iya sarrafa bayanai don ƙarin Docker mahalli masu rikitarwa.
Ta amfani da hanyoyin ajiya da hanyoyin rabawa a cikin Docker kamar Data Volumes
, rabawa na'ura mai masaukin baki, Data Volume Containers
, Bind Mounts
, da Docker Volume Plugins
, za ku iya sarrafa bayanai yadda ya kamata cikin sassauƙa da inganci a cikin Docker mahallin ku yayin tabbatar da daidaito da sauƙin samun bayanai.