銆婄簿閫欴ocker绗洓鐗堛€嬪畬鏁寸洰褰曪紙闄嗙画鏇存柊涓?..锛夛細
绗竴绔?Docker姒傝
绗簩绔?鍒涘缓瀹瑰櫒闀滃儚
绗笁绔?瀛樺偍鍜屽彂甯冮暅鍍?/strong>
绗洓绔?绠$悊瀹瑰櫒
绗簲绔?浣跨敤Docker Compose鍚姩澶氬鍣?/strong>
绗叚绔?浣跨敤Docker Machine銆乂agrant鍜孧ultipass
绗竷绔?灏?Linux瀹瑰櫒杩佽嚦Windows瀹瑰櫒
绗叓绔?浣跨敤Docker Swarm 鏋勫缓闆嗙兢
绗節绔?Portainer 鈥?涓€涓狣ocker鐨凣UI
绗崄绔?鍦ㄥ叕鏈変簯涓婅繍琛孌ocker
绗崄涓€绔?Docker鍜孠ubernetes鏋勫缓闆嗙兢
绗崄浜岀珷 鍙戠幇鏇村Kubernetes浣跨敤鏂瑰紡
绗崄涓夌珷 鍦ㄥ叕鏈変簯杩愯Kubernetes
绗崄鍥涚珷 瀵笵ocke鐜杩涜瀹夊叏鍔犲浐
绗崄浜旂珷 Docker宸ヤ綔娴?/strong>
绗崄鍏珷 Docker杩涢樁
娆㈣繋鏉ュ埌銆婄簿閫欴ocker绗洓鐗堛€嬶紒绗竴绔犲皢娑电洊浣犲簲璇ュ凡缁忔湁鎵€浜嗚В鐨凞ocker鍩虹鐭ヨ瘑銆備絾濡傛灉浣犲皻涓嶅叿澶囩浉搴旂煡璇嗭紝鏈珷灏嗗府鍔╀綘鍔犻€熶簡瑙g浉鍏冲熀纭€鐭ヨ瘑锛岃繖鏍峰涔犲悗缁珷鑺傚氨涓嶄細瑙夊緱鍥伴毦閲嶉噸銆傚湪瀛﹀畬鏈功鍚庯紝浣犲皢鎴愪负Docker澶х锛堜紶閿€鍗宠鎰燄煒傦級锛屽彲浠ュ湪浣犺嚜宸辩殑鐜涓疄鏂紻ocker锛屽熀浜庡畠鍒涘缓鍜岀淮鎶ゅ簲鐢ㄣ€?/p>
鏈珷涓紝鎴戜滑灏嗘潵鍥為【濡備笅楂樼骇鐭ヨ瘑锛?/p>
- 浜嗚В Docker
- 鐙珛涓绘満銆佽櫄鎷熸満鍜孌ocker涔嬮棿鐨勫尯鍒?/li>
- Docker瀹夎绋嬪簭鍜孌ocker瀹夎
- Docker鍛戒护
- Docker鍜屽鍣ㄧ敓鎬?/li>
鎶€鏈姹?/h2>
鏈珷涓紝鎴戜滑灏嗚璁哄浣曞湪鏈湴瀹夎Docker銆傝瀹炵幇瀹夎锛屾垜浠渶瑕佷竴涓繍琛岀潃浠ヤ笅浠绘剰涓€绉嶆搷浣滅郴缁熺殑瀹夸富鏈猴細
- macOS High Sierra鍙婁互涓婄増鏈?/li>
- Windows 10涓撲笟鐗?/li>
- Ubuntu 18.04鍙婁互涓?/li>
鏌ョ湅濡備笅瑙嗛涓殑瀹炴搷锛歨ttps://bit.ly/35fytE3
浜嗚ВDocker
鍦ㄨ繘琛孌ocker鐨勫畨瑁呬箣鍓嶏紝鎴戜滑鍏堟潵浜嗚ВDocker鎶€鏈墍鑷村姏浜庤В鍐崇殑闂銆?/p>
寮€鍙戜汉鍛?/h3>
Docker鑳屽悗鐨勫叕鍙告€绘槸灏嗚绋嬪簭鎻忚堪涓鸿В鍐斥€滃湪鎴戠殑鏈哄櫒涓婅繍琛屾甯糕€濈殑闂銆傝繖涓棶棰樻湁涓€寮犲浘鐗囨€荤粨鐨勬渶濂斤紝鏄竴寮犱互鈥滅伨闅惧コ瀛┾€濊糠鍥狅紙Disaster Girl meme锛変负搴曪紝娣诲姞浜?em>Worked fine in dev, ops problem now锛坉ev姝e父锛岃繍缁磋汉鏋級鐨勬枃妗堬紝鍑犲勾鍓嶅紑濮嬮绻佸嚭鐜板湪 PPT銆佽鍧涘拰Slack棰戦亾涓娿€傝櫧鐒跺緢鎼炵瑧锛屼絾涓嶅垢鐨勬槸杩欎篃鏄娣嬫穻鐨勭幇瀹烇紝鎴戣嚜宸变篃浜茶韩缁忓巻杩囪繖涓€鎯呭喌锛岃鎴戜滑鏉ョ湅鐪嬭繖绉嶉棶棰樼┒绔熶唬琛ㄤ粈涔堛€?/p>
璇戣€呮敞锛?/strong>鈥滅伨闅惧コ瀛┾€濈湡鍚峑o毛 Roth锛屽ス鍦ㄤ簰鑱旂綉涓婄殑椋庨潯婧愯嚜涓婂浘杩欏紶浠ョ伀鐏句负鑳屾櫙鐨勮糠涔嬪井绗戯紝鍚庢潵琚簰鑱旂綉涓婄殑鍚冪摐缇や紬浠?P 鍒版嘲鍧﹀凹鍏嬪彿銆佺弽鐝犳腐绛夊悇绉嶈儗鏅浘涓娿€傚師鐓х墖涓哄叾鐖朵翰鎵€鎷嶆憚锛岃儗鏅腑鐨勭伀鐏惧疄涓烘秷闃蹭汉鍛樻祴璇曟椂澶х伀銆?/p>
鍗充究鏄湪閬靛惊DevOps鏈€浣冲疄璺电殑涓栫晫閲岋紝浠嶇劧浼氬瓨鍦ㄥ紑鍙戣€呯殑宸ヤ綔鐜涓庢渶缁堢敓浜х幆澧冧笉鍖归厤鐨勬儏鍐点€?/p>
渚嬪锛屽紑鍙戣€呭彲鑳戒娇鐢╩acOS锛屽叾涓殑PHP鐗堟湰涓庢墭绠$敓浜т唬鐮佺殑Linux涓绘満涓婄殑鐗堟湰涓嶅尮閰嶃€傚嵆渚挎槸鐗堟湰鐩稿尮閰嶏紝鎴戜滑杩橀渶瑕佸鐞嗛厤缃互鍙婅繍琛岃PHP鐗堟湰鏁翠綋鐜鐨勪笉鍚岋紝涓句緥鏉ヨ锛屼竴涓綔鍦ㄧ殑闂鏄澶勭悊涓嶅悓鎿嶄綔绯荤粺鐗堟湰闂存枃鏈潈闄愬鐞嗘柟寮忎笉鍚岀殑闂銆?/p>
鎵€鏈夎繖浜涢兘浼氬鑷村湪寮€鍙戜汉鍛樺皢鑷繁鐨勪唬鐮侀儴缃插埌绾夸笂鏃讹紝鍗存棤娉曟甯歌繍琛屻€傞偅涔堟槸鍚﹀簲灏嗙敓浜х幆澧冭繘琛岄厤缃潵涓庡紑鍙戣€呯殑鐢佃剳鐩稿尮閰嶅憿锛屾垨鑰呮槸璁╁紑鍙戜汉鍛樺湪涓庣敓浜х幆澧冪浉涓€鑷寸殑宸ヤ綔鐜涓嬭繘琛屽紑鍙戝憿锛?/p>
鍦ㄧ悊鎯崇殑涓栫晫涓紝浠庡紑鍙戜汉鍛樼殑鐢佃剳鍒扮敓浜ф湇鍔″櫒鎵€鏈夊唴瀹归兘搴斾繚鎸佷竴鑷达紝浣嗚繖涓€涔屾墭閭﹂€氳繃浼犵粺鐨勬妧鏈毦浠ュ疄鐜般€傛瘡涓汉閮芥湁鑷繁鐨勫伐浣滀範鎯拰涓汉鍠滃ソ锛屽摢鎬曞彧鏈変竴涓郴缁熷伐绋嬪笀鍦ㄥ紑鍙戞椂寮哄埗璺ㄥ钩鍙扮殑涓€鑷存€у凡缁忓緢鍥伴毦浜嗭紝涓嶆秷璇翠竴涓伐绋嬪笀鍥㈤槦涓庢暟鐧句釜寮€鍙戜汉鍛樺悎浣滅殑鎯呭喌浜嗐€?/p>
鍦∕ac鎴朩indows涓婁娇鐢―ocker锛屽紑鍙戜汉鍛樺彲浠ュ緢杞绘槗鍦板皢浠g爜灏佽鍒颁粬浠嚜瀹氫箟鐨勫鍣ㄩ噷锛屾垨鑰呭湪涓庣郴缁熺鐞嗗憳鎴栬繍缁村洟闃熷悎浣滄椂灏嗗叾鍒涘缓涓轰竴涓狣ockerfile銆傛垜浠皢鍦?strong>绗簩绔?鍒涘缓瀹瑰櫒闀滃儚闂
Docker 瑙e喅鏂规
寮€鍙戜汉鍛樹粛鐒跺彲浠ラ€夋嫨鑷繁鍠滄鐨処DE锛屽苟鍦ㄥ紑鍙戜唬鐮佹椂淇濇寔鍘熸湁鐨勫伐浣滄祦銆傛垜浠湪鏈珷鐨勫悗缁儴鍒嗕腑浼氬彂鐜帮紝瀹夎鍜屼娇鐢―ocker涓€鐐归兘涓嶅洶闅撅紝鍏跺疄鑰冭檻鍒版浘缁忕淮鎶ょ幆澧冧竴鑷存€х殑绻佺悙锛屽摢鎬曟槸鏈夎嚜鍔ㄥ寲鐨勫姞鎸侊紝Docker浼氱畝鍗曞埌闅句互缃俊 鈥?鍍忔湁榄旀硶涓€鏍枫€?/p>
杩愮淮浜哄憳
浣滆€呭湪浠庝簨鐨勫骞磋繍缁村伐浣滀腑锛屽父甯镐細閬囧埌涓嬮潰鐨勯棶棰樸€?/p>
闂
鍋囪鎴戜滑鏈変簲鍙版湇鍔″櫒锛氫笁鍙伴厤缃簡璐熻浇鍧囪 鐨剋eb鏈嶅姟鍣紝涓ゅ彴閰嶇疆涓轰富浠庣敤浜庤繍琛屽簲鐢ㄤ竴鐨勬暟鎹簱鏈嶅姟鍣ㄣ€傛垜浠娇鐢ㄥ伐鍏稰uppet鎴朇hef鏉ヨ嚜鍔ㄧ鐞嗚蒋浠舵爤鍜?鍙版湇鍔″櫒涓婄殑閰嶇疆銆?/p>
涓€鍒囬兘寰堥『鍒╋紝鐩村埌鎺ュ埌鏂扮殑闇€姹傘€傛垜浠渶瑕佸皢搴旂敤浜岄儴缃插湪杩愯搴旂敤涓€鐩稿悓鐨勬湇鍔″櫒涓娿€傝〃闈笂娌℃湁浠讳綍闂锛屾垜浠彲浠ヤ慨鏀筆uppet鎴朇hef鐨勯厤缃潵娣诲姞鏂扮敤鎴枫€乿hosts銆佹媺鍙栨柊浠g爜锛岃濡傛绫汇€備絾鏄紝鎴戜滑娉ㄦ剰鍒板簲鐢ㄤ簩瑕佹眰浣跨敤姣斿簲鐢ㄤ竴鏇撮珮鐨勮蒋浠剁増鏈€?/p>
濡傛灉浜嬫儏鍐嶇碂绯曚竴浜涳紝鎴戜滑宸茬煡搴旂敤涓€绔姏閬垮厤涓庢柊鐨勮蒋浠舵爤杩涜鍏煎锛岃€屽簲鐢ㄤ簩鍙堜笉鍚戝悗鍏煎銆?/p>
浣跨敤浼犵粺鎶€鏈紝鎴戜滑鍙湁鍑犱釜閫夋嫨锛屾瘡涓€绉嶉兘浼氬湪鏌愮绋嬪害涓婂甫鏉ラ棶棰橈細
- 璇锋眰鏇村鐨勬湇鍔″櫒锛熻繖瀵逛紶缁熸妧鏈彲鑳芥渶瀹夊叏鐨勬妧鏈柟妗堬紝浣嗗苟涓嶆剰鍛崇潃浼氭湁棰勭畻鏉ユ坊缃洿澶氱殑璧勬簮銆?/li>
- 閲嶆柊鏋舵瀯鏂规锛熶粠璐熻浇鍧囪 鎴栦粠搴撲腑鎷垮嚭涓€鍙皐eb鏈嶅姟鍣ㄥ拰鏁版嵁搴撴湇鍔″櫒锛屼互搴旂敤浜岀殑杞欢鏍堥噸鏂拌繘琛岄儴缃诧紝鍦ㄦ妧鏈笂鍙兘鏄渶绠€鍗曠殑鏂规銆備絾鏄繖甯︽潵浜嗗簲鐢ㄤ簩鐨勫崟鐐归棶棰橈紝鍚屾椂涔熼檷浣庝簡搴旂敤涓€鐨勫啑浣欙細鎴戜滑涓€寮€濮嬩娇鐢?鍙皐eb鏈嶅姟鍣ㄥ拰2鍙版暟鎹簱鏈嶅姟鍣ㄥ彲鑳芥槸鏈夊師鍥犵殑銆?/li>
- 灏濊瘯鍦ㄦ垜浠殑鏈嶅姟鍣ㄤ笂鍚屾椂瀹夎鏂扮殑杞欢锛熷棷锛岃繖鑲畾浼氬甫鏉ラ棶棰橈紝鍒氬紑濮嬭繍琛岄」鐩椂杩欑湅璧锋潵鏄竴涓緢濂界殑鐭湡鏂规锛屼絾杩欑瓑浜庢垜浠墜涓婄殑鏄焊鐗屽眿锛屽湪闅忓悗浠绘剰杞欢鏍堥渶瑕佷弗閲嶅畨鍏ㄨˉ涓佹椂浼氭懅鏋媺鏈借埇宕╂簝銆?/li>
Docker 瑙e喅鏂规
杩欐鏄疍ocker鐨勯鍩熴€傚鏋滄妸搴旂敤涓€鏀惧湪涓夊彴鏈嶅姟鍣ㄧ殑瀹瑰櫒涓繍琛岋紝瀹為檯鍙互杩愯涓嶆涓変釜瀹瑰櫒锛屽弻鍊嶇殑瀹瑰櫒鎴戜滑灏卞彲浠ヨ繍琛?涓鍣紝璁╂垜浠彲浠ュ湪涓嶉檷浣庡簲鐢ㄤ竴鐨勫彲鐢ㄦ€х殑鍚屾椂閮ㄧ讲鎴戜滑鐨勫簲鐢ㄣ€?/p>
鍦ㄨ繖涓幆澧冮儴缃插簲鐢ㄤ簩浠呬粎闇€瑕佸湪3鍙颁富鏈轰笂鍚姩瀹瑰櫒骞朵娇鐢ㄨ礋杞藉潎琛¤矾鐢卞埌鏂伴儴缃茬殑搴旂敤涓娿€傚洜涓烘垜浠彧鏄湪瀹瑰櫒涓儴缃诧紝鏃犻渶鎷呭績鍦ㄥ悓涓€鍙版湇鍔″櫒涓婇儴缃层€侀厤缃拰绠$悊涓嶅悓鐗堟湰鐨勮蒋浠舵爤銆?/p>
鎴戜滑浼氬湪绗簲绔?浣跨敤Docker Compose鍚姩澶氬鍣?/strong>涓搷浣滀竴涓叿浣撶殑瀹炰緥銆?/p>
浼佷笟涔熸繁鍙楀墠杩扮浉鍚岄棶棰樼殑鍥版壈锛屽洜涓哄畠浠€氬父閮戒細鏈夊紑鍙戜汉鍛樺拰杩愮淮浜哄憳锛屼絾瀹冧滑鐨勮妯℃洿澶э紝鍥犳鍏锋湁鏇村ぇ鐨勯闄┿€?/p>
鍥犱负鍓嶉潰鎵€璇寸殑椋庨櫓锛屼互鍙婂畷鏈烘墍甯︽潵鐨勯攢鍞垨澹拌獕鐨勬崯澶憋紝浼佷笟闇€瑕佸湪鍙戝竷鍓嶅姣忎釜閮ㄧ讲杩涜娴嬭瘯銆傝繖琛ㄧず鍙戠敓濡備笅鎯呭喌鏃舵柊鍔熻兘鍜屼慨澶嶉兘浼氳9瓒充笉鍓嶏細 杩欎竴杩囩▼鍙兘瑕佽姳璐瑰嚑澶╁埌鏁板懆涔冭嚦鏁版湀鐨勬椂闂达紝鍙栧喅浜庡簲鐢ㄧ殑澶嶆潅鎬т互鍙婂紩鍏ュ彉鏇村瓨鍦ㄧ殑椋庨櫓銆傝櫧鐒跺湪鎶€鏈眰闈㈣繖涓€杩囩▼瑕佺‘淇濇寔缁€у拰鍙敤鎬э紝鍦ㄥ晢涓氬眰闈㈣繖鏄湪寮曞叆娼滃湪鐨勯闄┿€傚鏋滆繖涓€鏂板姛鑳藉湪杩囩▼涓彈闃伙紝鑰岀珵浜夊鎵嬫彁鍓嶅嚭浜嗕竴涓浉浼肩殑鍔熻兘锛屾垨鑰呮洿绯熺殑鏄竴涓浉鍚岀殑鍔熻兘锛?/p>
杩欎竴鎯呭舰瀵归攢鍞拰澹拌獕甯︽潵鐨勬崯浼ゅ拰鎴戜滑涓€寮€濮嬫墍绔姏閬垮厤鐨勫畷鏈烘槸涓€鏍风殑銆?/p>
棣栧厛瑕佽Docker骞朵笉浼氬厤闄や笂闈㈡垜浠墍鎻忚堪鐨勬搷浣滄祦绋嬨€備絾鏄垜浠篃璇翠簡锛屽畠浼氳宸茬粡杩炶疮杩愪綔鐨勪簨鎯呮洿涓虹畝鍗曘€傝繖琛ㄧず鎴戜滑鐨勫紑鍙戜滑鍙互鍦ㄤ笌鐢熶骇鐜鐩稿悓閰嶇疆鐨勫鍣ㄤ腑杩涜杩愯銆備篃鎰忓懗鐫€搴旂敤娴嬭瘯鐨勬柟娉曚笉浼氬お杩囩箒鏉傘€?/p>
姣斿锛屽湪寮€鍙戜汉鍛樻煡鐪嬩唬鐮佹椂锛屼粬浠煡閬撲唬鐮佸彲浠ュ湪鏈湴寮€鍙戠幆澧冧笂杩愯锛堝洜涓鸿繖姝f槸浠栦滑杩涜寮€鍙戠殑鐜锛夛紝鎴戜滑鐨勬祴璇曞伐鍏峰彲浠ュ惎鍔ㄧ浉鍚岀殑瀹瑰櫒鏉ヨ繘琛岃嚜鍔ㄥ寲娴嬭瘯銆備娇鐢ㄨ繃鐨勫鍣紝鍙互鍒犻櫎鎺夋潵閲婃斁璧勬簮杩涜涓嬮潰鐨勬祴璇曘€傝繖鎰忓懗鐫€绐佺劧闂存垜浠殑娴嬭瘯娴佺▼鍜岀幆鑺傚彉寰楁洿鍔犵伒娲伙紝骞朵笖鎴戜滑鍙互缁х画澶嶇敤鐩稿悓鐨勭幆澧冿紝鑰屼笉鏄负涓嬩竴濂楁祴璇曢噸鏂伴儴缃叉垨閲嶆柊鍒朵綔鏈嶅姟鍣ㄩ暅鍍忋€?/p>
杩欎竴娴佺▼鐢氳嚦鍙帹骞胯嚦灏嗘柊搴旂敤瀹瑰櫒鐩存帴鎺ㄥ埌鐢熶骇鐜涓€?/p>
杩欎竴杩囩▼瀹屾垚鐨勮秺蹇紝鎴戜滑灏辫秺鑳芥棤鍚庨【涔嬪咖鍦板揩閫熶笂绾挎柊鍔熻兘骞跺紩棰嗘疆娴併€?/p>
閭d箞锛屾垜浠煡閬撲簡Docker鎵€鑳借В鍐崇殑闂銆備笅闈㈤渶瑕佽璁虹殑鏄疍ocker鍒板簳鏄粈涔堜互鍙婂畠鑳藉仛浜涗粈涔堛€?/p>
Docker鏄竴涓鍣ㄧ鐞嗙郴缁燂紝甯姪鎴戜滑浠ヨ交鏉惧拰缁熶竴鐨勬柟寮忕鐞哃inux瀹瑰櫒锛圠XC锛夈€傝繖璁╂垜浠彲浠ュ湪绗旇鏈笂鐨勮櫄鎷熺幆澧冧腑鍒涘缓闀滃儚骞朵娇鐢ㄥ畠杩愯鍛戒护銆傚湪鏈湴鐢佃剳涓婅繍琛岃繖浜涚幆澧冧腑瀵瑰鍣ㄦ墍鎵ц鐨勬搷浣滐紝鍜屽湪鐢熶骇鐜涓繍琛岀浉鍚屽懡浠ゆ垨鎿嶄綔鐨勬晥鏋滄槸涓€鏍风殑銆?/p>
杩欐湁鍔╀簬鎴戜滑鍦ㄨ縼绉诲埌鐢熶骇鐜鏃舵棤闇€杩涜棰濆鐨勬搷浣滐紝姣斿浠庢湰鏈哄皢搴旂敤涓婄嚎鍒扮敓浜х幆澧冩湇鍔″櫒銆備笅闈㈡垜浠潵鐪嬩笅Docker瀹瑰櫒鍜屽吀鍨嬬殑铏氭嫙涓绘満鐜鏈夊摢浜涘尯鍒細 鍥?.1 鍦ㄨ櫄鎷熶富鏈虹幆澧冭繍琛屽簲鐢?/p>
鍙互鐪嬪嚭锛屽浜庣嫭绔嬩富鏈烘垜浠殑涓変釜搴旂敤鍚屾椂鍏变韩鐩稿悓鐨勬鑹茬殑杞欢鏍堛€傚湪铏氭嫙涓绘満涓婅繍琛屼笁涓簲鐢紝鍒欏彲浠ヤ娇鐢ㄤ袱涓畬鍏ㄤ笉鍚岀殑杞欢鏍堛€備笅鍥炬樉绀轰簡浣跨敤Docker杩愯鐩稿悓鐨勪笁涓簲鐢細 鍥?.2 鍦?Docker 涓婅繍琛屽簲鐢?/p>
杩欏紶鍥句腑璁╂垜浠竻鏅板湴鐪嬪埌浣跨敤Docker鐨勫叧閿ソ澶勶紝鍗筹紝鏃犻渶鍦ㄦ瘡娆″惎鍔ㄥ鍣ㄦ椂鍒涘缓涓€涓畬鏁寸殑鎿嶄綔绯荤粺锛岃繖缂╁噺浜嗗鍣ㄥ崰鐢ㄧ殑鎬荤┖闂淬€傚洜涓烘墍鏈夌殑Linux鐗堟湰閮戒娇鐢ㄦ爣鍑嗗唴鏍告ā鍨嬶紝Docker渚濊禆浜庡涓绘満鎿嶄綔绯荤粺濡俁ed Hat, CentOS鍜孶buntu鐨凩inux鍐呮牳銆?/p>
鍥犳锛屾垜浠嚑涔庡彲浠ュ皢鎵€鏈夌殑Linux鎿嶄綔绯荤粺浣滀负瀹夸富鏈烘搷浣滅郴缁燂紝骞跺彲瀵逛富鏈轰笂鍏跺畠鍩轰簬Linux鐨勬搷浣滅郴缁熻繘琛屽垎灞?銆備篃灏辨槸瀵逛簬搴旂敤鏉ヨ鏄畨瑁呬簡瀹屾暣鐨勬搷浣滅郴缁燂紝鑰岀幇瀹炴槸鎴戜滑浠呭畨瑁呬簡浜岃繘鍒舵枃浠讹紝濡傚寘绠$悊鍣ㄣ€丄pache/PHP浠ュ強鎿嶄綔绯荤粺涓繍琛屽簲鐢ㄦ墍闇€瑕佺殑涓€浜涘叾瀹冨簱銆?/p>
渚嬪锛屽湪鍓嶅浘涓紝鎴戜滑鍙互鐢≧ed Hat杩愯姗欒壊搴旂敤锛孌ebian杩愯缁胯壊搴旂敤锛屼絾缁濅笉闇€瑕佸湪涓绘満涓婂疄闄呭畨瑁匯ed Hat 鎴朌ebian銆傚洜鑰孌ocker鐨勫彟涓€涓ソ澶勬槸瀹冩墍鍒涘缓鐨勯暅鍍忕殑澶у皬銆傚湪鍒涘缓鏃舵棤闇€閭d簺澶у潡鏂囦欢锛氬唴鏍告垨鎿嶄綔绯荤粺銆傝繖璁╅暅鍍忓緢灏忓緢绱у噾锛屾槗浜庤縼绉汇€?/p>
棣栧厛鎴戜滑闇€瑕佺殑鏄畨瑁呭櫒锛圛nstaller锛夛紝鍦ㄦ湰鍦版満鍣ㄥ拰鏈嶅姟鍣ㄧ幆澧冧腑杩愯Docker銆備笅闈㈡潵鐪嬪摢浜涚幆澧冧腑鍙互瀹夎Docker锛?/p>
姝ゅ鎴戜滑鍙互鍦ㄥ叕鏈変簯涓繍琛孌ocker锛屽 AWS锛圓mazon Web Services锛夈€丮icrosoft Azure鍜孌igitalOcean锛岃繖鍙槸寰堝皯涓€閮ㄥ垎銆傞€氳繃鍓嶉潰鍒楀嚭鐨勪笉鍚岀被鍨嬬殑瀹夎鍣紝Docker鍦ㄦ搷浣滅郴缁熶笂杩愯鐨勬柟寮忓叾瀹炲苟涓嶇浉鍚屻€備緥濡傦紝Docker鍦↙inux涓婂師鐢熻繍琛岋紝鎵€浠ュ浣跨敤鐨勬槸Linux锛岃€屽鏋滀娇鐢ㄧ殑鏄痬acOS鎴朩indows 10锛岃繍琛屾柟寮忓垯鏈変簺璁镐笉鍚岋紝鍥犱负瀹冮渶瑕佷緷璧栦簬Linux銆?/p>
涓嬮潰鍒嗗埆鏉ョ湅鍦?Ubuntu 18.04 Linux妗岄潰銆乵acOS鍜學indows 10涓婂揩閫熷畨瑁匘ocker銆?/p>
鍓嶉潰宸茬粡鎻愬埌锛岃繖鏄笁绉嶇郴缁熶腑瀹夎鏈€涓虹洿鎺ョ殑涓€绉嶃€傛垜灏嗗皢鍦║buntu 18.04涓婂畨瑁匘ocker锛屼絾瀹為檯鏈夊绉嶅彂琛岀増鏈殑 Linux锛屽悇鑷湁鐫€涓嶅悓鐨勫寘绠$悊鍣紝澶勭悊鏂瑰紡涓婄◢鏈変笉鍚屻€傚弬瑙佹墿灞曢槄璇婚儴鍒嗕簡瑙d笉鍚?Linux 鍙戣鐗堜腑鐨勫畨瑁呮柟寮忋€傚畨瑁?Docker锛屼粎闇€鍦═erminal涓繍琛屽涓嬪懡浠わ細 瀹夎涓細瑕佹眰灏嗗綋鍓嶇敤鎴峰姞鍒癉ocker鐢ㄦ埛缁勪腑銆傝瀹炵幇娣诲姞锛岃繍琛屽涓嬪懡浠ゅ嵆鍙紝瑕佽寰楀皢鍏朵腑鐨?username鏇挎崲鎴愪綘鑷繁鐨勫摝锛?/p>
杩欎簺鍛戒护浼氳嚜琛屼笅杞姐€佸畨瑁呭苟閰嶇疆鏈€鏂扮増鐨凞ocker銆傚湪鍐欐湰涔︽椂锛岄€氳繃瀹樻柟瀹夎鑴氭湰鍦↙inux鎿嶄綔绯荤粺涓婂畨瑁呯殑鐗堟湰涓?9.03銆?/p>
杩愯濡備笅鍛戒护鏉ョ‘璁ocker鏄惁宸插畨瑁呭苟杩愯锛?/p>
浣犲簲璇ヤ細鐪嬪埌绫讳技濡備笅鐨勮緭鍑猴細 鍥?1.3 浣跨敤 docker version 鍛戒护鏄剧ず绯荤粺涓畨瑁呯殑 Docker 鐗堟湰鐨勮緭鍑?/p>
鏈変竴涓敮鎸佸伐鍏峰皢鍦ㄥ悗缁珷鑺備腑浣跨敤鍒帮紝鍦╩acOS鍜學indows 10瀹夎鍣ㄤ腑閮戒細浣滀负Docker鐨勪竴閮ㄥ垎杩涜瀹夎銆?/p>
瑕佺‘淇濆湪鍚庨潰鐨勭珷鑺備腑鏈夎繖浜涘伐鍏峰彲浠ヤ娇鐢紝鐜板湪鎴戜滑搴旇繘琛屽畨瑁呫€傝繖涓€宸ュ叿鐨勫悕绉颁负Docker Compose锛岃瀹夎瀹冿紝棣栧厛鎴戜滑搴旇幏鍙栧埌鏈€鏂扮殑鐗堟湰鍙枫€傚彲閫氳繃璁块棶GitHub椤甸潰https://github.com/docker/compose/releases/鐨勭増鏈儴鍒嗘潵杩涜鏌ョ湅 绗竴涓伐鍏锋槸Docker Machine銆傝瀹夎瀹冿紝棣栧厛鎴戜滑搴旇幏鍙栧埌鏈€鏂扮殑鐗堟湰鍙枫€傚彲閫氳繃璁块棶GitHub椤甸潰https://github.com/docker/machine/releases/鐨勫彂甯冪増鏈儴鍒嗘潵杩涜鏌ョ湅銆傚湪鍐欐湰涔︽椂锛屾渶鏂扮増鏈负1.25.4锛岃鑰呭湪瀹夎鏃跺彲灏嗗涓嬩唬鐮佸潡涓殑鐗堟湰鍙峰湪鍛戒护涓互鏈€鏂扮殑鐗堟湰鍙锋潵杩涜鏇挎崲锛?/p>
瑕佷笅杞藉苟瀹夎鎺ヤ笅鏉ヨ繖涓伐鍏稤ocker Compose锛岄渶瑕佽繍琛屼笅闈㈢殑鍛戒护锛屽悓鏍疯鍦ㄥ彂琛岀増鏈〉闈ttps://github.com/docker/compose/releases鏌ョ湅杩愯鏃剁殑鏈€鏂扮増鏈細 涓€鏃﹀畬鎴愪簡瀹夎锛屾垜浠彲浠ヨ繍琛屽涓嬪懡浠ゆ潵纭畾鐩稿叧鐗堟湰鐨勮蒋浠惰繘琛屼簡姝g‘瀹夎锛?/p>
鎴戜滑瀛︿範浜嗗湪Linux涓婂畨瑁咃紝涓嬮潰灏卞涔犲浣昺acOS杩涜瀹夎銆?/p>
鍜孡inux涓婄殑鍛戒护琛屽畨瑁呬笉鍚岋紝Docker鍦∕ac涓婃湁涓€涓浘褰㈠寲瀹夎绋嬪簭銆?/p>
鈩癸笍鍦ㄨ繘琛屼笅杞藉墠锛岀‘淇濇墍杩愯鐨勭郴缁熶负Apple macOS Yosemite 10.10.3 鎴栦互涓婄殑鐗堟湰锛屽洜涓鸿繖鏄垜浠湪鏈功涓墍璁ㄨDocker 鐗堟湰鎵€闇€鐨勬渶浣庣郴缁熺増鏈€傚鏋滀綘杩愯鐨勬槸鏇磋€佺殑鐗堟湰锛屼笉蹇呮媴蹇冿紝杩樻槸鍙互瀹夎鐨勶紝鍙傜収鏈珷鈥滄洿鑰佺殑鎿嶄綔绯荤粺鈥濅竴鑺傘€?/p>
涓嬮潰鍦?macOS 涓婂畨瑁?Docker锛?/p>
杩涘叆Docker鍟嗗簵鍦板潃涓猴細鐐瑰嚮杩欓噷 鐐瑰嚮Get Docker杩欎竴閾炬帴 涓嬭浇鐨勬槸涓€涓狣MG瀹夎鍖呫€傚弻鍑诲畨瑁呭寘灏变細鎸傝浇闀滃儚锛屾闈笂鎵撳紑鐨勬寕杞介暅鍍忓涓嬪浘鎵€绀猴細 鍥?.4 鈥?macOS涓奃ocker瀹夎鍣ㄧ殑鎷栨嫿瀹夎鐣岄潰 鍦ㄥ皢Docker鍥炬爣鎷栨嫿鍒癆pplications鏂囦欢澶逛腑涔嬪悗锛屽弻鍑诲浘鏍囧氨浼氭彁绀轰綘鏄惁瑕佹墦寮€鎵€涓嬭浇鐨勭▼搴忋€?/p> 鐐瑰嚮Yes浼氭墦寮€Docker瀹夎绋嬪簭锛屽涓嬫墍绀猴細 鍥?.5 Docker 瀹夎鍣ㄥ脊鍑虹獥鍙?/p>
鐐瑰嚮OK浼氬嚭鐜颁竴涓緭鍏ュ瘑鐮佺殑瀵硅瘽妗嗐€傚畬鎴愬瘑鐮佽緭鍏ュ悗浼氬湪灞忓箷宸︿笂瑙掑浘鏍囨爮涓湅鍒颁竴涓狣ocker鍥炬爣銆?/p> 鐐瑰嚮璇ュ浘鏍囧苟閫夋嫨About Docker浼氬嚭鐜板涓嬮〉闈細 鍥?.6 鍏充簬 Docker鐣岄潰 杩樺彲浠ュ湪鍛戒护琛岃繍琛屽涓嬪懡浠ゆ潵鏌ョ湅涓?Docker Engine 涓€璧峰畨瑁呯殑Docker Compose鐨勭増鏈細 鎴戜滑宸茬粡瀛︿範浜嗗浣曞湪macOS涓婂畨瑁匘ocker锛屼笅闈㈠氨杩涘叆鏈珷鏈€涓€涓搷浣滅郴缁焀indows 10涓撲笟鐗堛€?/p>
鍜屽湪Mac涓婂畨瑁匘ocker涓€鏍凤紝Windows涓婂畨瑁匘ocker涔熶娇鐢ㄥ浘褰㈠寲瀹夎绋嬪簭銆?/p>
鈩癸笍娉ㄦ剰锛氬湪涓嬭浇鍓嶏紝纭繚杩愯鐨勪负Microsoft Windows 10涓撲笟鐗堟垨浼佷笟鐗?4浣嶇郴缁熴€傚鏋滆繍琛岀殑鏄洿鑰佺殑鐗堟湰鎴栬€匴indows 10鐨勫叾瀹冪増鏈紝杩樻槸鍙互杩愯Docker鐨勶紝鍙傜収鏈珷鈥滄洿鑰佹搷浣滅郴缁熲€濅竴鑺備簡瑙f洿澶氫俊鎭€俉indows涓婄殑Docker鏈夎繖涓€瑕佹眰锛屾槸鍑轰簬瀵笻yper-V鐨勪緷璧栥€侶yper-V鏄疻indows鐨勫師鐢熻櫄鎷熸満锛屽厑璁稿湪Windows涓婅繍琛寈86-64瀹㈡埛绔紝绯荤粺鍙互涓篧indows 10涓撲笟鐗堟垨Windows鏈嶅姟鍣ㄧ増銆傚畠鐢氳嚦褰㈡垚浜哫box One鎿嶄綔绯荤粺鐨勪竴閮ㄥ垎銆?/p>
鎴戜滑鏉ュ湪Windows涓婂畨瑁匘ocker鍚э細 鍦―ocker鍟嗗簵涓笅杞絎indows鐗堢殑Docker瀹夎绋嬪簭锛屽湴鍧€涓虹偣鍑昏繖閲?/p> 鐐瑰嚮Get Docker鎸夐挳涓嬭浇瀹夎鍣ㄣ€?br>
璇戣€呮敞锛?/strong>涓嶆兂娉ㄥ唽鐨勬湅鍙嬪彲鐩存帴璁块棶涓嬭浇閾炬帴锛氱偣鍑昏繖閲屻€?/p> 涓嬭浇鍚庯紝杩愯瀹夎鍖咃紝灏变細鐪嬪埌濡備笅鐨勬杩庝俊鎭細 鍥?.7 Windows涓奃ocker瀹夎鍣ㄧ殑閰嶇疆鐣岄潰 淇濈暀閰嶇疆涓洪粯璁ゅ€硷紝鐒跺悗鐐瑰嚮OK銆傝繖鏃朵細鍦╓indows涓婂畨瑁匘ocker鎵€闇€鐨勬墍鏈夌粍浠讹細 鍥?.8 Docker瀹夎涓晫闈?/p>
瀹夎涔嬪悗锛屼細寮瑰嚭瑕佹眰閲嶅惎銆傚彧闇€鐐瑰嚮Close and restart鎸夐挳鍗冲彲锛?/p>
鍥?.9 Docker瀹夎瀹屾垚纭鐣岄潰 閲嶅惎鍚庯紝灏卞彲浠ョ湅鍒板睆骞曞彸涓嬭鍥炬爣鎵樼洏涓湁涓€涓狣ocker鍥炬爣銆傜偣鍑诲浘鏍囧苟閫夋嫨鑿滃崟涓殑About Docker浼氭樉绀哄涓嬪唴瀹癸細 鍥?.10 Docker About Me椤甸潰 鎵撳紑PowerShell绐楀彛骞惰緭鍏ュ涓嬪懡浠わ細 浼氭樉绀轰笌Mac鍜孡inux鐗堟湰鐩镐技鐨勮緭鍑猴細 鍚屾牱锛屾垜浠繕鍙互杩愯濡備笅鍛戒护鏉ユ煡鐪嬩笌Docker Engine鍚屾椂瀹夎鐨凞ocker Compose鐨勭増鏈細 鍚屾牱浼氱湅鍒颁笌macOS鍜孡inux鐗堟湰涓婄浉浼肩殑杈撳嚭銆備綘鍙兘宸茬粡鎬荤粨鍑猴紝鍦ㄥ畬鎴愬寘鐨勫畨瑁呭悗锛屼娇鐢ㄤ笂浼氭瀬鍏剁浉浼笺€傝繖浜涘皢鍦ㄦ湰绔犵◢鍚庝娇鐢?Docker 鍛戒护涓€鑺傝缁嗚鏄庛€?/p>
濡傛灉鎵€杩愯鐨凪ac鎴朩indows鎿嶄綔绯荤粺涓嶅鏂帮紝鏈弧瓒宠姹傦紝閭d箞灏遍渶瑕佷娇鐢―ocker Toolbox銆傛€濊€冧笅杩愯濡備笅鍛戒护鎵€鎵撳嵃鐨勮緭鍑猴細 鍦ㄨ嚦姝ゆ垜浠墍瀹夎鐨勪笁涓増鏈腑锛岄兘浼氭樉绀轰袱涓増鏈彿锛氬鎴风鍜屾湇鍔$銆傚彲浠ラ娴嬪埌锛孡inux鐗堟湰涓樉绀虹殑瀹㈡埛绔拰鏈嶅姟绔灦鏋勫潎涓篖inux锛屼絾鍦∕ac鐗堟湰涓樉绀哄鎴风杩愯鍦―arwin涓婏紝杩欐槸Apple鐨勭被Unix鍐呮牳锛屽湪Windows涓婃樉绀虹殑鐗堟湰涓篧indows銆備絾涓よ€呯殑鏈嶅姟绔殑鏋舵瀯鍧囨樉绀轰负Linux锛岃繖鏄€庝箞鍥炰簨鍛紵 杩欐槸鍥犱负Mac鍜學indows鐨凞ocker瀹夎鐗堟湰閮藉湪鍚庡彴杩愯浜嗚櫄鎷熸満锛岃€岃繖涓€铏氭嫙鏈鸿繍琛屼簡涓€涓皬鍨嬨€佽交閲忕殑鍩轰簬Alpine Linux鐨勬搷浣滅郴缁熴€傝櫄鎷熸満浣跨敤Docker鑷韩搴撹繍琛岋紝涓庢墍浣跨敤鐨勭幆澧冨唴缃殑Hypervisor杩涜杩炴帴銆?/p>
macOS 涓唴缃殑涓篐ypervisor.framework锛學indows涓负Hyper-V銆?/p>
涓虹‘淇濇墍鏈変汉閮借兘浣撻獙Docker锛孌ocker鏈変竴涓笉浣跨敤鍐呯疆hypervisor鐨勭増鏈紝鍙湪鑰佺増鏈殑macOS浠ュ強鏈敮鎸佺殑Windows鐗堟湰涓娇鐢ㄣ€傝繖浜涚増鏈埄鐢╒irtualBox鏉ヤ綔涓篽ypervisor杩愯Linux鏈嶅姟绔紝渚涘鎴风杩炴帴銆?/p>
鈩癸笍娉ㄦ剰锛?/strong>VirtualBox鏄竴涓敱Oracle寮€鍙戠殑寮€婧恱86鍜孉MD64/Intel64铏氭嫙鍖栦骇鍝併€傚彲杩愯浜嶹indows銆丩inux銆丮acintosh鍜孲olaris涓绘満涓婏紝鏀寔璁稿Linux銆乁nix鍜學indows瀹㈡埛鎿嶄綔绯荤粺銆?/p>
鏇村鏈夊叧VirtualBox鐨勭煡璇嗭紝璇疯闂甴ttps://www.virtualbox.org/銆?/p>
鏇村鏈夊叧Docker Toolbox鐨勭煡璇嗭紝鍙傝椤圭洰缃戠珯锛屽彲浠ュ湪鍙戝竷鐗堟湰椤甸潰涓嬭浇鍒癿acOS鍙奧indows瀹夎绋嬪簭銆?/p>
灏忚创澹細鏈功鍋囧畾璇昏€呭凡鍦↙inux涓婂畨瑁呬簡鏈€鏂扮増Docker锛屾垨浣跨敤Mac鎴朩indows涓婄殑Docker銆傝櫧鐒朵娇鐢―ocker Toolbox瀹夎鐨凞ocker搴旇鍙互杩愯鏈功鐨勫懡浠わ紝浣嗚鑰呭彲鑳戒細閬囧埌涓€浜涙枃浠舵潈闄愪互鍙婁粠鏈満鍚戝鍣ㄦ寕杞芥暟鎹殑鎵€鏈夋潈鐨勯棶棰樸€?/p>
鏃㈢劧鍦ㄨ嚜宸辩郴缁熼噷瀹夎濂戒簡Docker锛屾垜浠氨鏉ヨ瑙d竴浜涘彲浠ユ湁鏁堜娇鐢―ocker鐨勫懡浠ゃ€?/p>
浣犲彲鑳藉凡鐔熺煡浜嗕竴浜汥ocker鍛戒护銆備絾杩囦竴閬嶆墍鏈夌殑鍛戒护杩樻槸鍊肩殑銆傛垜浠細鍏堢湅涓€浜涘父鐢ㄥ懡浠わ紝鐒跺悗瀛︿範鐢ㄤ簬Docker闀滃儚鐨勪竴浜涘懡浠ゃ€備箣鍚庢繁鍏ュ埌瀹瑰櫒浣跨敤鐨勭浉鍏冲懡浠ゃ€?/p>
灏忚创澹細Docker閲嶆瀯浜嗗懡浠よ瀹㈡埛绔潵瀵瑰懡浠よ繘琛屾洿绗﹀悎閫昏緫鐨勫垎缁勶紝杩欐槸鍥犱负瀹㈡埛绔彁渚涚殑鍔熻兘鏁伴噺鍦ㄥ揩閫熷闀匡紝骞朵笖鍛戒护瀛樺湪浜ゅ弶閲嶅彔鐨勬儏鍐点€傚湪鏈功涓垜浠皢浣跨敤杩欎竴鏂扮殑缁撴瀯锛岃€屼笉鏄鎴风宸叉湁鐨勯偅浜涘揩鎹峰懡浠ゃ€?/p>
鎴戜滑瑕佹潵鐪嬬殑绗竴涓懡浠ゆ槸鏈€鏈夌敤鐨勫懡浠や箣涓€锛屼笉浠呮槸鍦―ocker涓紝瀵规垜浠娇鐢ㄧ殑浠讳綍鍛戒护琛屽伐鍏烽兘鏄繖鏍凤細help鍛戒护銆備粎闇€濡備笅杩欐牱杩愯锛?/p>
杩欎竴鍛戒护浼氬垪鍑烘墍鏈夊彲鐢ㄧ殑Docker鍛戒护锛屽苟浼存湁涓€涓畝鐭殑鎻忚堪璇存槑姣忎釜鍛戒护鐨勫姛鑳姐€傛垜浠細鍦?strong>绗洓绔?绠$悊瀹瑰櫒浼佷笟
闂
Docker 瑙e喅鏂规
鐙珛涓绘満銆佽櫄鎷熸満鍜孌ocker涔嬮棿鐨勫尯鍒?/h2>
瀹夎Docker
鍦↙inux (Ubuntu 18.04)涓婂畨瑁匘ocker
$ curl -sSL https://get.docker.com/ | sh
浣跨敤濡備笂鍛戒护鑻ヨ緝鎱紝鍙敼涓?/h2>
$ sudo apt install docker.io
$ sudo systemctl start docker
$ sudo usermod -aG docker username
$ docker version
$ COMPOSEVERSION=1.25.4
$ curl -L https://github.com/docker/compose/releases/download/$COMPOSEVERSION/docker-compose-`uname -s`-`uname -m` >/tmp/docker-compose
$ chmod +x /tmp/docker-compose
$ sudo mv /tmp/docker-compose /usr/local/bin/docker-compose
$ docker-compose version
鍦╩acOS涓婂畨瑁匘ocker
璇戣€呮敞锛?/strong>涓嶆兂娉ㄥ唽鐨勬湅鍙嬪彲鐩存帴璁块棶涓嬭浇閾炬帴锛氱偣鍑昏繖閲?/p>
$ docker-compose version
鍦╓indows 10涓撲笟鐗堜笂瀹夎Docker
$ docker version
鍥?.11 docker version鍛戒护鐨勮緭鍑?
$ docker-compose version
鏇磋€佺殑鎿嶄綔绯荤粺
$ docker version
浣跨敤Docker鍛戒护
$ docker help
$ docker <COMMAND> --help
涓嬩竴姝ワ紝鎴戜滑鏉ヨ繍琛宧ello-world瀹瑰櫒銆備粎闇€閫氳繃杩愯濡備笅鍛戒护鏉ュ疄鐜帮細
$ docker container run hello-world
涓嶇敤鎷呭績杩愯Docker鐨勪富鏈猴紝鍦↙inux, macOS鍜學indows涓婄殑鏁堟灉鏄竴鏍风殑銆侱ocker浼氫笅杞絟ello-world瀹瑰櫒闀滃儚骞舵墽琛岋紝鍦ㄦ墽琛屽悗锛屽氨浼氬仠姝㈠鍣ㄣ€?/p>
Terminal浼氳瘽涓殑缁撴灉绫讳技杩欐牱锛?/p>
鍥?.12 docker container run hello-world鍛戒护鐨勮繍琛岃緭鍑?/p>
璁╀滑鏉ュ仛杩涗竴姝ョ殑鎺㈤櫓锛氶€氳繃杩愯濡備笅涓ゆ潯鍛戒护涓嬭浇骞惰繍琛屼竴涓狽ginx瀹瑰櫒锛?/p>
$ docker image pull nginx
$ docker container run -d --name nginx-test -p 8080:80 nginx
鈩癸笍NGINX鏄竴娆惧紑婧恮eb鏈嶅姟鍣紝鍙敤浜庤礋杞藉潎琛°€侀偖浠朵唬鐞嗐€佸弽鍚戜唬鐞嗕箖鑷矵TTP缂撳瓨銆?/p>
绗竴鏉″懡浠や笅杞絅ginx瀹瑰櫒闀滃儚锛岀浜屾潯鍛戒护鍦ㄥ悗鍙板惎鍔ㄥ鍣紝鍚嶄负nginx-test锛屼娇鐢ㄧ殑鏄垜浠墍鎷夊彇鐨凬ginx闀滃儚銆傚悓鏃惰繕灏嗗鍣ㄧ殑绔彛80涓庡涓绘満涓婄殑8080绔彛杩涜浜嗘槧灏勶紝杩欐牱鍦ㄦ湰鍦版祻瑙堝櫒涓€氳繃http://localhost:8080/鍗冲彲璁块棶銆?/p>
鍙互浠庡涓嬫埅鍥句腑鐪嬪嚭锛岃鍛戒护杩愯鐨勭粨鏋滃湪涓夌鎿嶄綔绯荤粺涓兘鏄竴鏍风殑銆備互涓嬫槸 Linux 涓殑缁撴灉锛?/p>
鍥?.13 鍦↙inux涓婅繍琛宒ocker image pull nginx鐨勮緭鍑?/p>
鈩癸笍涓€鐪肩湅涓婂幓Linux鍜宮acOS鐣岄潰寰堢浉浼笺€傝繖鏄洜涓烘垜鍦ㄤ娇鐢↙inux杩滅▼涓绘満锛屽悗缁珷鑺備腑浼氳瑙e浣曞疄鐜般€?/p>
浠ヤ笅鏄痬acOS涓婄殑杩愯缁撴灉锛?/p>
鍥?.14 macOS涓婃墽琛宒ocker image pull nginx鍚庣殑杈撳嚭
浠ヤ笅鏄?Windows 涓婄殑杩愯缁撴灉锛?/p>
鍥?.15 Windows涓婅繍琛宒ocker image pull nginx鍛戒护鐨勮緭鍑?/p>
鍦ㄦ帴涓嬫潵鐨勪笁绔犱腑锛屾垜浠細鏉ユ繁鍏ュ湴瀛︿範Docker鍛戒护琛屽鎴风鐨勪娇鐢ㄣ€傝繖閲屾垜浠厛杩愯濡備笅鍛戒护鍋滄骞跺垹闄ゆ垜浠殑nginx-test瀹瑰櫒锛?/p>
$ docker container stop nginx-test
$ docker container rm nginx-test
鍙互鐪嬪埌锛岃繍琛岀畝鍗曠殑Nginx瀹瑰櫒鍦ㄥ畨瑁呬簡Docker鐨勪笁鍙颁富鏈轰笂鐨勪綋楠屾槸瀹屽叏涓€鑷寸殑銆?鐩镐俊浣犱篃鑳芥兂璞″埌锛屽鏋滀笉浣跨敤Docker鎯宠鍦ㄤ笁绉嶅钩鍙颁笂瀹炵幇杩欐牱鐨勬晥鏋滄槸闈炲父鍏锋湁鎸戞垬鎬х殑锛屽湪姣忎釜骞冲彴涓婄殑浣撻獙涔熶細涓嶅悓銆傝繖涔熸槸鏇剧粡鏈湴寮€鍙戠幆澧冩墍浜х敓涓嶅悓鐨勫師鍥狅紝鍥犱负浜轰滑闇€瑕佷笅鍏蜂綋骞冲彴鐨勫畨瑁呯▼搴忥紝骞跺湪鎵€杩愯骞冲彴涓婅繘琛屾湇鍔¢厤缃€傚悓鏍凤紝鍚屾椂鍦ㄥ钩鍙伴棿鐨勫姛鑳戒篃鍙兘浼氫笉鍚屻€?/p>
鎴戜滑宸茬粡瀛︿範浜咲ocker鍛戒护鐨勫熀纭€锛屼笅闈㈠皢鐩厜鎶曞悜鏇村ぇ鐨勫鍣ㄧ敓鎬佸惂銆?/p>
Docker鍜屽鍣ㄧ敓鎬?/h2>
濡傛灉浣犱竴鐩村湪杩介殢Docker鍜屽鍣ㄧ殑鍙戝睍鐨勮瘽锛屼細娉ㄦ剰鍒版渶杩戝嚑骞碊ocker缃戠珯涓婂彂甯冪殑娑堟伅寮€濮嬫湁鎵€鍙樺寲锛屽ご鏉$敱浠€涔堟槸瀹瑰櫒杞负鏇村鑱氱劍鍦―ocker浣滀负涓€瀹跺叕鍙告彁渚涗粈涔堟湇鍔°€?/p>
杩欏叾涓殑涓€涓牳蹇冮┍鍔ㄦ槸鏇剧粡鎵€鏈夌殑涓滆タ閮借鍫嗙爩鍦ㄤ竴璧峰苟绉颁箣涓篋ocker锛岃繖浼氬甫鏉ュ洶鎯戙€傛棦鐒剁幇鍦ㄤ汉浠凡缁忔棤闇€鍐嶆帴鍙椾粈涔堟槸瀹瑰櫒浠ュ強Docker鑳借В鍐充粈涔堥棶棰樼殑鏁欒偛锛岃鍏徃闇€瑕佹姄绱т笌甯傞潰涓婇洦鍚庢槬绗嬭埇鐨勬彁渚涘悇绫诲鍣ㄦ妧鏈殑鍏跺畠鍏徃杩涜鍖哄垎銆?/p>
涓嬮潰鎴戜滑灏辨潵灏濊瘯鎷嗚ВDocker锛屽寘鍚涓嬮儴鍒嗭細
- 寮€婧愰」鐩細鏈夊緢澶氱敱Docker鍚姩鐨勫紑婧愰」鐩紝鐜板湪鐢变竴涓ぇ鐨勫紑鍙戣€呯ぞ鍖烘潵杩涜缁存姢銆?/li>
-
Docker, Inc.锛?/strong>鏄竴瀹朵负鏀寔鍜屽紑鍙戞牳蹇僁ocker宸ュ叿鎴愮珛鐨勫叕鍙搞€?/li>
- Docker CE鍜孌ocker EE锛?/strong>杩欐槸鏋勫缓鍦ㄥ紑婧愮粍浠朵箣涓婄殑鏍稿績Docker宸ュ叿闆嗐€?/li>
鎴戜滑杩樹細鍦ㄥ悗闈㈢珷鑺備腑鐪嬪埌涓€浜涘叾瀹冪涓夋柟鏈嶅姟銆傚悓鏃讹紝鎴戜滑鏉ヨ缁嗕簡瑙d互涓婅繖浜涳紝鍏堜粠寮€婧愰」鐩紑濮嬨€?/p>
寮€婧愰」鐩?/h3>
Docker, Inc.鍦ㄨ繃鍘诲嚑骞翠腑寮€婧愬苟鎹愮尞浜嗕竴鎵硅嚜鍚戠殑鏍稿績椤圭洰缁欏悇涓紑婧愬熀閲戝拰绀惧尯銆傝繖浜涢」鐩寘鍚細
- Moby椤圭洰鏄竴涓笂娓搁」鐩紝Docker Engine灏辨槸鍩轰簬杩欎竴椤圭洰鐨勩€傚畠鎻愪緵浜嗙粍瑁呭叏鍔熻兘瀹瑰櫒绯荤粺鎵€闇€鐨勫叏閮ㄧ粍浠躲€?/li>
- Runc鏄竴涓敤浜庡垱寤哄拰閰嶇疆瀹瑰櫒鐨勫懡浠よ鎺ュ彛锛屽畠鎸夌収OCI锛圤racle Call Interface锛夎鏍艰繘琛岀殑鏋勫缓銆?/li>
- Containerd鏄竴涓槗浜庡祵鍏ョ殑瀹瑰櫒杩愯鏃躲€傚畠涔熸槸Moby椤圭洰鐨勬牳蹇冪粍浠躲€?/li>
- LibNetwork鏄竴涓负瀹瑰櫒鎻愪緵缃戠粶鏈嶅姟鐨凣o璇█搴撱€?/li>
- Notary鏄竴涓棬鍦ㄦ彁渚涚鍚嶅鍣ㄩ暅鍍忕殑淇′换绯荤粺鐨勫鎴风鍜屾湇鍔$銆?/li>
- HyperKit鏄竴涓厑璁告垜浠湪鑷繁鐨勫簲鐢ㄤ腑鍐呭祵hypervisor鍔熻兘鐨勫伐鍏烽泦锛屽綋鍓嶄粎鏀寔macOS鍜孒ypervisor妗嗘灦銆?/li>
- VPNKit涓篐yperKit鎻愪緵VPN鍔熻兘銆?/li>
- DataKit鍏佽鎴戜滑浣跨敤绫讳技Git鐨勫伐浣滄祦缂栨帓搴旂敤鏁版嵁銆?/li>
- SwarmKit鏄竴涓厑璁告垜浠娇鐢ㄥ拰Docker Swarm鐩稿悓鐨凴aft涓€鑷存€х畻娉曟潵鏋勫缓鍒嗗竷寮忕郴缁熴€?/li>
- LinuxKit鏄竴涓厑璁告垜浠负杩愯瀹瑰櫒缂栬瘧灏忓瀷渚挎惡寮廘inux鎿嶄綔绯荤粺鐨勬鏋躲€?/li>
- InfraKit鏄竴涓垜浠彲浠ョ敤浜庡畾涔夎繍琛孡inuxKit鐢熸垚鐨勫彂琛岀増鏈殑鍩虹鏋舵瀯鐨勫伐浣滈泦銆?/li>
鎴戜滑鍙兘姘歌繙涓嶄細鐙珛鍦颁娇鐢ㄥ崟涓殑缁勪欢锛屼絾鏄紝鎵€鎻愬埌鐨勬瘡涓」鐩兘鏄敱Docker, Inc缁存姢鐨勫伐鍏风殑缁勪欢銆傛垜浠細鍦ㄦ渶鍚庝竴绔犱腑鏇存繁鍏ュ湴浜嗚В杩欎簺椤圭洰銆?/p>
Docker, Inc.
Docker, Inc.鏈€鍒濇槸涓哄紑鍙慏ocker CE鍜孌ocker EE鎵€褰㈡垚鐨勫叕鍙搞€傚畠杩樻浘涓篋ocker EE鎻愪緵鍩轰簬SLA鐨勬敮鎸佹湇鍔★紝鍚戞兂瑕佸宸叉湁搴旂敤瀹瑰櫒鍖栧苟鍔犲叆MTA锛圡odernize Traditional Apps锛夐」鐩殑鍏徃鎻愪緵鍜ㄨ鏈嶅姟銆?/p>
璇昏€呭彲鑳戒細娉ㄦ剰鍒板湪涓婁竴鍙ヤ腑鎴戞彁鍙婂緢澶氬唴瀹规椂浣跨敤浜嗚繃鍘绘椂銆傝繖鏄洜涓?019骞?1鏈圖ocker, Inc.杩涜浜嗛噸缁勶紝灏嗗叾骞冲彴涓氬姟鍑哄敭缁欎簡涓€瀹跺悕涓篗irantis Inc鐨勫叕鍙搞€傝鍏徃浠嶥ocker, Inc.骞惰喘鐨勮祫浜у寘鎷細
- Docker Enterprise, 鍖呮嫭Docker EE
- Docker Trusted Registry
- Docker Unified Control Plane
- Docker CLI
Mirantis Inc.鏄竴瀹跺姞宸炲叕鍙革紝鑱氱劍浜嶰penStack鍜孠ubernetes鐩稿叧瑙e喅鏂规鐨勫紑鍙戝拰鏀寔銆傛槸闈炶惀鍒╃粍缁嘜penStack鍩洪噾浼氱殑鍒涘鑰呬箣涓€锛屾嫢鏈夊ぇ閲忔彁渚涗紒涓氱骇鏀寔鏈嶅姟鐨勭粡楠屻€?/p>
鏈夎浆杞借鍓岲ocker, Inc. CEO Rob Bearden锛屽湪閫€浣嶅悗涓嶄箙鍚庤浜嗗涓嬬殑璇濓細
鍦ㄤ笌绠$悊鍥㈤槦鍜岃懀浜嬩細杩涜浜嗘繁鍏ョ殑鍒嗘瀽鍚庯紝鎴戜滑鍐冲畾Docker鏈変袱绉嶉潪甯镐笉鍚岀殑涓氬姟锛氫竴鏄椿璺冪殑寮€鍙戜笟鍔★紝浜屾槸澧為暱鐨勪紒涓氱涓氬姟銆傛垜浠繕鍙戠幇瀹冧滑鐨勪骇鍝佸拰閲戣瀺妯″瀷鏈夊緢澶у樊鍒€傝繖瀵艰嚧鎴戜滑鍐冲畾閲嶇粍鍏徃骞舵媶鍒嗚繖涓ら」涓氬姟锛屽浜庡鎴峰強鎸叴Docker鐨勪骇涓氱粺鎴樺紩棰嗘妧鏈兘鏄渶濂界殑閫夋嫨銆?/p>
浼佷笟绔笟鍔$洰鍓嶅綊灞濵irantis Inc.锛孌ocker, Inc. 鑱氱劍浜庨€氳繃Docker Desktop 鍜?Docker Hub鎻愪緵鏇村ソ鐨勫紑鍙戣€呭伐浣滄祦锛岃鐢ㄦ埛寰椾互閬垮厤閬彈鍘傚晢閿佸畾锛坴endor lock-in锛夌殑濞佽儊銆?/p>
Docker CE鍜孌ocker EE
鏈夊緢澶欴ocker, Inc鎻愪緵鍜屾敮鎸佺殑宸ュ叿銆傛湁浜涘墠闈㈠凡缁忔彁鍒帮紝鍙︿竴浜涘皢浼氬湪鍚庣画绔犺妭涓鍒般€傚湪缁撴潫绗竴绔犱箣鍓嶏紝鎴戜滑搴旀湁涓€涓皢瑕佷娇鐢ㄧ殑宸ュ叿鐨勬蹇点€傚叾涓渶閲嶈鐨勫氨鏄唴鏍窪ocker Engine銆?/p>
杩欐槸Docker鐨勬牳蹇冿紝鎴戜滑璁茶В鐨勬墍鏈夊叾瀹冨伐鍏烽兘浼氫娇鐢ㄥ畠銆傛垜浠凡浣跨敤浜咲ocker寮曟搸锛屽洜涓哄湪瀹夎Docker鏃跺凡瀵瑰叾杩涜浜嗗畨瑁呬互鍙婂湪鏈珷Docker鍛戒护涓€鑺傝繘琛屼簡浣跨敤銆傜洰鍓嶆湁涓や釜鐗堟湰鐨凞ocker寮曟搸锛孌ocker浼佷笟鐗堬紙EE锛夛紝褰撳墠鐢盡irantis Inc.缁存姢锛屼互鍙奃ocker绀惧尯鐗堬紙CE锛夈€傛湰涔﹀皢浣跨敤鐨勬槸Docker CE銆?/p>
浠?018骞?鏈堣捣锛孌ocker CE鐨勭ǔ瀹氱増鍙戝竷鍛ㄦ湡涓轰竴骞翠袱娆★紝涔熷氨鏄鏈?涓湀鐨勭淮鎶ゅ懆鏈熴€傝繖琛ㄧず浣犳湁瓒冲鐨勬椂闂村鏌ュ苟涓哄崌绾у仛鍑嗗銆傚湪鍐欐湰涔︽椂锛屽綋鍓岲ocker CE鍙戣鐗堢殑鏃堕棿琛ㄤ负锛?/del>
Docker 18.06 CE:锛?/strong>杩欐槸鎸夊鍙戝竷Docker CE鐨勬渶鍚庝竴鐗堬紝鍙戝竷鏃堕棿涓?018骞?鏈?8鏃ャ€?/del>Docker 18.09 CE锛?/strong>2018骞?鏈堝簳銆?0鏈堝垵鍙戝竷锛屾槸Docker CE鍙戝竷鍛ㄦ湡鏀逛负姣忓崐骞寸殑绗竴涓彂琛岀増銆?/del>Docker 19.03 CE锛?/strong>棰勮鍦?019骞?鏈?4鏈堝彂甯冪殑19骞存敮鎸佺殑绗竴鐗圖ocker CE銆?/del>Docker 19.09 CE锛?/strong>2019骞寸殑绗簩涓敮鎸佺増鏈紝棰勮鍦?019骞?鏈?10鏈?鍙戝竷銆?/del>
鍦ㄥ彂甯僁ocker CE绋冲畾鐗堟湰鐨勫悓鏃讹紝Docker浼氶€氳繃nightly浠撳簱锛堟鍓嶇殑Docker CE Edge锛夋彁渚汥ocker Engine鐨刵ightly鏋勫缓鐗堟湰锛屽悓鏃堕€氳繃Edge娓犻亾鎸夋湀鍙戝竷Mac鍙奧indows鐗堢殑Docker銆?/p>
Docker杩樻彁渚涘涓嬪伐鍏峰拰鏈嶅姟锛?/p>
- Docker Compose锛氬厑璁告垜浠畾涔夊拰鍒嗕韩澶氬鍣ㄥ畾涔夌殑宸ュ叿锛屽湪绗簲绔?浣跨敤Docker Compose鍚姩澶氬鍣?/strong>涓細璇︾粏璁茶В銆?/li>
- Docker Machine锛氫竴涓敤浜庡湪澶氬钩鍙颁笂鍚姩Docker涓绘満鐨勫伐鍏凤紝鍦?strong>绗叚绔?浣跨敤Docker Machine銆乂agrant鍜孧ultipass
涓細杩涜璁茶В銆?/li> - Docker Hub锛欴ocker瀹瑰櫒鐨勪粨搴擄紝鍦ㄦ帴涓嬫潵鐨勪笁绔犱腑浼氳瑙c€?/li>
- Docker for Mac锛氭湰绔犱腑宸茶瑙e湪 Mac 涓婂畨瑁?Docker銆?/li>
- Docker for Windows锛氭湰绔犱腑宸茶瑙e湪 Windows 涓婂畨瑁?Docker銆?/li>
- Docker Swarm锛氫竴涓彲璇嗗埆澶氫富鏈虹殑缂栨帓宸ュ叿锛屽湪绗叓绔?浣跨敤Docker Swarm 鏋勫缓闆嗙兢涓細璇︾粏璁茶В銆傜洰鍓嶇敱Mirantis Inc缁存姢銆?/li>
鎬荤粨
鏈珷涓紝鎴戜滑璁茶В浜嗕竴浜涘彲鑳藉湪瀛︿範鏈珷鍓嶄綘宸茬粡鐭ラ亾锛堣嚦灏戠幇鍦ㄧ煡閬擄級鐨勭煡璇嗐€傛垜浠鍏堝涔犱簡浠€涔堟槸Docker鐨勫熀纭€鐭ヨ瘑锛屼互鍙婄浉瀵瑰叾瀹冧富鏈虹被鍨嬫湁浠€涔堝ソ澶勩€傛垜浠瑙d簡瀹夎绋嬪簭锛屽湪涓嶅悓鎿嶄綔绯荤粺涓殑杩愯鏂瑰紡锛屼互鍙婂浣曢€氳繃鍛戒护琛屾潵杩涜鎺у埗銆備竴瀹氳璁板緱鏌ョ湅瀹夎绋嬪簭鐨勮姹傦紝鏉ョ‘淇濅綘浣跨敤瀵瑰簲鎿嶄綔绯荤粺鐨勬纭畨瑁呯▼搴忋€?/p>
鐒跺悗鎴戜滑娣卞叆鍒癉ocker鐨勪娇鐢紝骞惰瑙d簡涓€浜涘紑濮嬩娇鐢ㄧ殑鍩烘湰鍛戒护銆傛垜浠細鍦ㄦ湭鏉ョ殑绔犺妭涓潵瀛︿範鎵€鏈夌殑绠$悊鍛戒护锛屾繁鍏ョ悊瑙h繖浜涘懡浠や互鍙婂浣曘€佷綍鏃朵娇鐢ㄨ繖浜涘懡浠ゃ€傛渶鍚庯紝鎴戜滑璁ㄨ浜咲ocker鐢熸€佺郴缁熶互鍙婁笉鍚屽伐鍏峰悇鑷壙鎷呯殑鑱岃矗銆?/p>
涓嬩竴绔犱腑锛屾垜浠細鏉ュ涔犲浣曟瀯寤篵ase瀹瑰櫒锛屽苟娣卞叆瀛︿範Dockerfile鍜屽瓨鍌ㄩ暅鍍忕殑浣嶇疆锛屼互鍙婄幆澧冨彉閲忓拰Docker鏁版嵁鍗风殑浣跨敤銆?/p>
璇惧悗闂
- 鍦ㄥ摢閲屽彲浠ヤ笅杞組ac鍜學indows鐨凞ocker妗岄潰瀹夎鍖咃紵
- 浣跨敤浠€涔堝懡浠ゆ潵涓嬭浇 Nginx 闀滃儚锛?/li>
- 鍝竴涓紑婧愰」鐩槸鏍稿績Docker Engine鐨勪笂娓搁」鐩紵
- 鐩墠鏄摢瀹跺叕鍙稿湪缁存姢 Docker 浼佷笟鐗堬紵
- 杩愯鍝釜鍛戒护鏉ユ煡鎵綝ocker瀹瑰櫒鍛戒护瀛愰泦鐨勬洿澶氫俊鎭紵
鎵╁睍闃呰
浠ヤ笅鍏徃鍙備笌浜?Docker 鐨勭淮鎶わ細
- Docker, Inc.
- Mirantis Inc.
- Docker閲嶆瀯
鏈珷涓垜浠璁轰簡濡備笅鐨刪ypervisors锛?/p>
- macOS Hypervisor妗嗘灦
- Hyper-V
鏈夊叧濡備綍鍦ㄥ叾瀹僉inux鍙戣鐗堜腑杩涜瀹夎锛屽弬瑙丏ocker瀹樻柟鏂囨。涓殑瀹夎Docker Engine 椤甸潰銆?/p>
鎴戜滑鍙傝€冧簡Docker鐨勫涓嬪崥瀹㈡枃绔狅細
- Docker CLI閲嶆瀯鍗氬鏂囩珷
- Docker鎵╁睍鏀寔澹版槑
鎺ョ潃鎴戜滑璁ㄨ浜嗗涓嬪紑婧愰」鐩細
- Moby椤圭洰: https://mobyproject.org/
- Runc: https://github.com/opencontainers/runc
- Containerd: https://containerd.io/
- LibNetwork; https://github.com/docker/libnetwork
- Notary: https://github.com/theupdateframework/notary
- HyperKit: https://github.com/moby/hyperkit
- VPNKit: https://github.com/moby/vpnkit
- DataKit: https://github.com/moby/datakit
SwarmKit: https://github.com/docker/swarmkitLinuxKit: https://github.com/linuxkit/linuxkitInfraKit: https://github.com/docker/infrakitOCI缁嗗垯: https://github.com/opencontainers/runtime-spec/
鏈€鍚庯紝鍦ㄦ湰绔犲紑濮嬪鎵€璁ㄨ鐨勮糠鍥犲彲鍦ㄨ繖閲屾煡鐪嬶細
Worked fine in Dev, Ops problem now锛歨ttp://www.developermemes.com/2013/12/13/worked-fine-dev-ops-problem-now/