Sarrafa bayanai a cikin Docker: Ajiye da Raba bayanai a ciki Docker

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 adana container bayanai.
  • Yi amfani da --volume ko -v zaɓi don ƙirƙira da haɗa ƙarar bayanai zuwa container. Misali, docker run -v mydata:/data yana ƙirƙira ƙarar bayanai mai suna mydata kuma ya haɗa shi zuwa ga /data directory a cikin container.
  • Data volumes za a iya raba tsakanin container, 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 cikin container. Duk wani sabuntawa ga kundin adireshi da aka raba yana nunawa nan da nan a cikin container.

 

Amfani Data Volume Containers

  • Data volume containers an sadaukar da su containers don adanawa da raba bayanai. An halicce su don sarrafa su kawai data volumes.
  • Ƙirƙirar ƙarar bayanai container ta amfani da docker create umarnin kuma haɗa shi zuwa wani containers 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 ɗaya containers.

 

Amfani Bind Mounts

  • Bind mounts ba da damar raba kai tsaye na kundayen adireshi na injin runduna tare da containers 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 cikin container. Canje-canje ga kundin adireshi ana nunawa nan da nan a cikin container.

 

Amfani Docker Volume Plugins

  • Docker yana goyan bayan volume plugin kari don ajiya da sarrafa bayanai akan dandamali daban-daban.
  • Plugins kamar RexRay, Flocker, ko GlusterFS 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.