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

Dockerfileを素早く書くtips&ライブデモ

 Dockerfileを素早く書くtips&ライブデモ

2016/10/21 JX通信社の社内勉強会で話した内容です

Mitsuki Ogasahara

October 21, 2016
Tweet

More Decks by Mitsuki Ogasahara

Other Decks in Technology

Transcript

  1. w ࠷ۙࣗ෼͕ॻ͍ͨ%PDLFSpMF w EPDLFSDPNQPTF w BQFY w NFDBC w +6."/

     w FUDʜ Recently… %PDLFSΠϝʔδΛڞ༗͢Ε͹
 AEPDLFSSVOA͚ͩͰ.BDͰ΋8JOEPXTͰ΋-JOVYͰ΋ ར༻Ͱ͖ΔΑ͏ʹʂ
  2. Bad Practice to Write Dockerfile FROM alpine RUN apk add

    —no-cache curl RUN command to take long time RUN some typo command 8SJUF%PDLFSpMF
  3. Bad Practice to Write Dockerfile $ docker build . &SSPS

    ... ... /bin/sh: typo: not found The command '/bin/sh -c typo' returned a non-zero code: 127
  4. Best Practice to Write Dockerfile $ vim Dockerfile $ docker

    run -it alpine /bin/sh &EJU%PDLFSpMF 3VOCBTFJNBHF`TTIFMM
  5. Best Practice to Write Dockerfile / # 8SJUFKVTUPOFMJOF FROM alpine

    RUN apk add —no-cache curl 4IFMMJTSVOOJOH
  6. Best Practice to Write Dockerfile / # apk add —no-cache

    curl &YFDVUFPOFMJOFWJB4-*.& FROM alpine RUN apk add —no-cache curl
  7. Best Practice to Write Dockerfile / # apk add —no-cache

    curl &YFDVUFPOFMJOFWJB4-*.& FROM alpine RUN apk add —no-cache curl
  8. / # some command Best Practice to Write Dockerfile /

    # apk add —no-cache curl … &YFDVUFPOFMJOFWJB4-*.& FROM alpine RUN apk add —no-cache curl RUN some command
  9. / # some command … Best Practice to Write Dockerfile

    / # apk add —no-cache curl … &YFDVUFPOFMJOFWJB4-*.& FROM alpine RUN apk add —no-cache curl RUN some command RUN other command / # other command