Upgrade to Pro — share decks privately, control downloads, hide ads and more …

boot2docker 사용시 컨테이너에서 생성한 데이터를 유지하기

seapy
January 26, 2015

boot2docker 사용시 컨테이너에서 생성한 데이터를 유지하기

Docker 코리아 캐주얼 토크에서 발표한 자료

seapy

January 26, 2015
Tweet

More Decks by seapy

Other Decks in Programming

Transcript

  1. # boot2docker ࢎਊद ஶప੉ցীࢲ ࢤࢿೠ ؘ੉ఠܳ ਬ૑ೞח ߑߨ * ഐझ౟

    ஹೊఠ੄ /Users ಫ؊ী ݃਍౟ * boot2docker о࢚ݠन ղࠗ੄ ಫ؊ী ݃਍౟ * ࠅܬ ஶప੉ց ࢎਊ
  2. # ഐझ౟ ஹೊఠ੄ /Users ಫ؊ী ݃਍౟ ``` $ docker run

    \ -p 5432:5432 \ -v ~/postgresql:/var/lib/postgresql/data \ postgres:9.4 ``` ``` initdb: could not create directory "/var/lib/postgresql/data/global": Permission denied ```
  3. boot2docker ח `bootdocker up` प೯द ׮਺җ э੉ ഐझ౟ ಫ؊ܳ VM

    ਵ۽ ݃ ਍౟ * Users share at /Users * /Users share at /Users * c/Users share at /c/Users * /c/Users share at /c/Users * c:/Users share at /c/Users
  4. boo2docker ীࢲ /Users ܳ docker:staff ҅੿ਸ ࢎਊ೧ ੗زਵ۽ ݃਍౟ ஶప੉ցীࢲ

    ࢜۽਍ ҅੿ ࢤࢿद boot2docker ৬ ׮ܲ UID/GID ܳ о૑ѱػ׮. ౵ੌ ࢤࢿҗ ࢏ઁח ಫ؊ ӂೠਸ 777۽ ߸҃೧ ೧Ѿ ೞ૑݅ ೞ݂٘௼ ࢤࢿ਷ VirtualBox੄ ߡӒ۽ (https://www.virtualbox.org/ticket/818) ৈ੹൤ ز੘ೞ૑ ঋח׮. ҙ۲ ੉ग : https://github.com/boot2docker/boot2docker/issues/581#issuecomm ent-60309186 > ഐझ౟੄ ؘ੉ఠܳ ߄۽ ੍ਸ ҃਋ ਬਊ > ࠛ೙ਃೞѱ ഐझ౟੄ ౵ੌ ߂ ಫ؊੄ ӂೠਸ ߸҃೧ঠ ೧ঠ ೠ׮
  5. # boot2docker о࢚ݠन ղࠗ੄ ಫ؊ী ݃਍౟ ``` $ docker run

    \ -p 5432:5432 \ -v /var/lib/boot2docker/postgresql:/var/lib/postgresql/data \ postgres:9.4 ``` `boot2docker init` ݺ۸য प೯द ׮਺ 2ѐ੄ о࢚٣झ௼ܳ ࢤࢿೞҊ VMী ݃਍౟ * /var/lib/docker * /var/lib/boot2docker > о࢚ ٣झ௼ח `boot2docker delete` ݺ۸য प೯द ࢏ઁ
  6. # ࠅܬ ஶప੉ց ࢎਊ ``` $ docker run --name pg-data

    \ -v /var/lib/postgresql/data \ busybox $ docker run \ -p 5432:5432 \ --volumes-from pg-data \ postgres:9.4 ``` > ࠅܬ ஶప੉ց੄ ؘ੉ఠח `/var/lib/docker` о ૑ਕ૑૑ ঋחೠ ਬ૑
  7. # Ѿۿ DB੄ ؘ੉ఠܳ ਬ૑ दఃח ਊب۽ ࠅܬ ஶప੉ց ࢎਊ,

    ഐझ౟੄ ؘ੉ఠܳ ੍ӝ ਤೠ ਊب۽ /Users ݃਍౟