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

Dockerイメージ置き場の件

ozzozz
September 16, 2016

 Dockerイメージ置き場の件

ozzozz

September 16, 2016
Tweet

More Decks by ozzozz

Other Decks in Technology

Transcript

  1. ᶄ  %PDLFS)VC΍2VBZJPͳͲͷQVCMJD%PDLFS SFHJTUSZ •  EPDLFSQVMMίϚϯυͰͷΠϝʔδμ΢ϯϩʔυ ݩɺ͔ͭEPDLFSQVTIίϚϯυͰͷΠϝʔδ ΞοϓϩʔυઌͱͳΓ͏Δ •  Πϯλʔωοτͷ୭Ͱ΋μ΢ϯϩʔυͰ͖ΔΠ ϝʔδͷஔ͖৔͸QVCMJDSFQPTJUPSZɺಛఆͷਓ

    ͚͕ͩμ΢ϯϩʔυͰ͖ΔΠϝʔδͷஔ͖৔͸ QSJWBUFSFQPTJUPSZͱݺ͹ΕΔʢΑͶʁʣ •  QSJWBUFSFQPTJUPSZͷ࡞੒͸༗ྉͩͬͨΓ͢Δ •  ͲͪΒͷSFQPTJUPSZ΋EPDLFSQVTIʹ͋ͨͬ ͯ͸Ϣʔβೝূཁ •  EPDLFSίϚϯυͰSFHJTUSZΛಛʹࢦఆ͠ͳ ͚Ε͹σϑΥϧτͰ%PDLFS)VC͕࢖ΘΕΔ %PDLFSΠϝʔδஔ͖৔ͷόϦΤʔγϣϯᶄ
  2. ᶅ  ࣗલͰཱͯΔQSJWBUF%PDLFSSFHJTUSZ •  EPDLFSQVMMίϚϯυͰͷΠϝʔδμ΢ϯ ϩʔυݩɺ͔ͭEPDLFSQVTIίϚϯυͰͷ ΠϝʔδΞοϓϩʔυઌͱͳΓ͏Δ •  -"/ͱ͔ϓϥΠϕʔτΫϥ΢υͱ͔71$಺ ʹཱͯΔ͜ͱͰɺΠϝʔδͷμ΢ϯϩʔυ ઌΞοϓϩʔυݩΛݶఆͰ͖Δ

    •  QSJWBUFSFQPTJUPSZ΋ఏڙͰ͖Δ •  %PDLFS͕ࣾ044ʹ͍ͯ͠ΔSFHJTUSZͰ΋ ఏڙՄೳʹͳͬͯͨʢ͍ͭͷؒʹʂʁʣ TFFhttps://docs.docker.com/registry/deploying/#/ restricting-access %PDLFSΠϝʔδஔ͖৔ͷόϦΤʔγϣϯᶅ
  3. •  ՝ۚͳ͠Ͱ%PDLFSΠϝʔδΛൿಗ͢ΔͨΊʹ •  QVCMJDSFHJTUSZ͕ఏڙ͢ΔQSJWBUF SFQPTJUPSZͰ͸৘ใ؅ཧʹෆ҆Λ๊͔ΕΔ ΤϯλʔϓϥΠζ স ͳ͓٬༷ʹ •  खݩͷෳ਺ͷ%PDLFSϗετؒͰ%PDLFSΠ

    ϝʔδΛ࢖͍ճͨ͢Ίʹ •  ϦϞʔτ͔ΒͷΠϝʔδμ΢ϯϩʔυ͸஗ ͍ͷͰɺಡΈࠐΈΩϟογϡͱͯ͠ •  $*ʹΑͬͯසൟʹΠϝʔδΛ࡞੒͢ΔͷͰɺ ςετ༻ΠϝʔδͷҰ࣌తஔ͖৔ॴͱͯ͠ QSJWBUF%PDLFSSFHJTUSZͷ࢖͍Ͳ͜Ζ
  4. ˞%PDLFSࣾ੡044൛SFHJTUSZΛ࢖͏લఏ •  ·ͣ͸͓ࢼ͠Ͱ%PDLFSίϯςφͱͯ͠ىಈ͢Δ  •  3FHJTUSZʹอଘ͢Δ%PDLFSΠϝʔδΛ%PDLFSϗετ্ͷϑΝΠϧ γεςϜͰӬଓԽ͢Δ •  )5514ͰαʔϏε͢Δ ͪΌΜͱͨ͠ূ໌ॻΛ࢖͑͹޾ͤʹͳΕΔΑʂʲޙड़ʳ

     QSJWBUF%PDLFSSFHJTUSZͷͭ͘Γ͔ͨᶃ $ docker run -d -p 5000:5000 registry:2 $ docker run -d -p 5000:5000 \ -v /srv/registry:/var/lib/registry \ registry:2 $ docker run -d -p 5000:5000 \ -v /srv/registry-certs:/certs \ -e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \ -e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \ registry:2
  5. ˞(6*΋΄͍͠Ͱ͠ΐʁ͋ΔΑ QSJWBUF%PDLFSSFHJTUSZͷͭ͘Γ͔ͨᶄ $ docker run -d -p 8080:80 \ -e

    ENV_DOCKER_REGISTRY_HOST: 192.168.0.1 \ -e ENV_DOCKER_REGISTRY_PORT: 5000 \ konradkleine/docker-registry-frontend:v2
  6. •  %PDLFS)VCΛ࢖͏৔߹ •  )551ͰαʔϏε͞Ε͍ͯΔSFHJTUSZΛ࢖͏৔߹ •  )5514ͰαʔϏε͞Ε͍ͯΔSFHJTUSZΛ࢖͏৔߹ EPDLFSίϚϯυͰͷSFHJTUSZࢦఆ $ docker pull

    ozz/hoge $ docker login $ docker tag hogehoge ozz/hoge $ docker push ozz/hoge $ docker pull 192.168.0.1:5000/ozz/hoge $ docker tag hoge 192.168.0.1:5000/ozz/hoge $ docker push 192.168.0.1:5000/ozz/hoge $ docker pull reg.nttlabs.info:5000/ozz/hoge $ docker tag hoge reg.nttlabs.info:5000/ozz/hoge $ docker push reg.nttlabs.info:5000/ozz/hoge ˞ͨͩ͠ɺEPDLFSσʔϞϯʹJOTFDVSFSFHJTUSZͷઃఆཁʲޙड़ʳ ˞ͨͩ͠ɺSFHJTUSZ͕ΦϨΦϨূ໌ॻͳͲݕূύε͕ແޮͳαʔόূ໌ॻΛ ɹ࢖༻͍ͯ͠Δ৔߹͸ɺEPDLFSσʔϞϯʹJOTFDVSFSFHJTUSZͷઃఆཁʲޙड़ʳ
  7. •  FUDEFGBVMUEPDLFSʹઃఆΛ௥Ճ͠ɺ %PDLFSσʔϞϯΛ࠶ىಈ 6CVOUV 6QTUBSUΛ࠾༻ ͷ JOTFDVSFSFHJTUSZઃఆ $ sudo vim

    /etc/default/docker === DOCKER_OPTS="--insecure-registry=192.168.0.1:5000" === $ sudo service docker restart
  8. 6CVOUV TZTUFNEΛ࠾༻ ͷ JOTFDVSFSFHJTUSZઃఆ •  FUDTZTUFNETZTUFNEPDLFSTFSWJDFE഑Լ ʹઃఆϑΝΠϧΛ௥Ճ͠ɺTZTUFNEʹ৽ͨͳઃ ఆΛೝࣝͤ͞ɺ%PDLFSσʔϞϯΛ࠶ىಈ $ sudo

    mkdir /etc/systemd/system/docker.service.d/ $ sudo vim /etc/systemd/system/docker.service.d/ insecure-registry.conf === [Service]! ExecStart=! ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry=192.168.0.1:5000! === $ sudo systemctl daemon-reload $ sudo systemctl show docker $ sudo systemctl restart docker.service