{"id":131,"date":"2021-04-26T01:08:28","date_gmt":"2021-04-25T16:08:28","guid":{"rendered":"https:\/\/auto.meto4d.pgw.jp\/blog\/?p=131"},"modified":"2021-12-21T21:04:33","modified_gmt":"2021-12-21T12:04:33","slug":"windows10%e3%81%abk8s%e3%81%ae%e5%b0%8e%e5%85%a5%e3%81%a8%e3%83%81%e3%82%a7%e3%83%83%e3%82%af%e3%81%a8docker%e3%81%a8","status":"publish","type":"post","link":"https:\/\/auto.meto4d.pgw.jp\/blog\/?p=131","title":{"rendered":"Windows10\u306bk8s\u306e\u5c0e\u5165\u3068\u30c1\u30a7\u30c3\u30af\u3068docker\u3068"},"content":{"rendered":"\n<p>\u3084\u3070\u3044<br>\u3053\u306e\u307e\u307e\u3058\u3083\u30b3\u30f3\u30c6\u30ca\u958b\u767a\u30de\u30f3\u306b\u306a\u3063\u3066\u3057\u307e\u3046<\/p>\n\n\n\n<p>PHP8\u3092\u8a66\u3057\u305f\u3088\u3068\u304bpython\u5f04\u3063\u305f\u3088\u3068\u304b\u3063\u3066\u8a18\u4e8b\u3092\u66f8\u3053\u3046\u3068\u601d\u3063\u305f\u306e\u306b\u30b3\u30f3\u30c6\u30ca\u306e\u65b9\u3070\u3063\u304b\u308a\u3044\u3058\u3063\u3066\u308b\u6c17\u304c\u3059\u308b<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2>\u80cc\u666f<\/h2>\n\n\n\n<p>k8s\u306eingress\u3092\u8a66\u3057\u305f\u304b\u3063\u305f\u3000\u304c\u4e00\u756a\u306e\u76ee\u7684<br>\u30b3\u30f3\u30c6\u30ca\u3067\u7ba1\u7406\u3057\u3066\u3044\u304f\u6642\u3001nginx\u3067rewrite\u3068\u304blocation\u3068\u304b\u5206\u3051\u3066php\u3084\u3089python\u3084\u3089\u306b\u98db\u3070\u3057\u3066\u308b\u90e8\u5206\u3092\u3082\u3046service\u3067rewrite\u3057\u3066fast-cgi:\/\/\u306b\u76f4\u63a5\u98db\u3070\u3057\u305f\u307b\u3046\u304c\u3044\u3044\u3093\u3058\u3083\u306a\u3044\u304b\u3063\u3066\u601d\u3063\u305f<\/p>\n\n\n\n<p>\u305d\u306e\u524d\u6bb5\u968e\u3067docker build\u3067\u4f5c\u3063\u305f\u81ea\u524d\u30b3\u30f3\u30c6\u30ca\u3092k8s\u3067\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u307e\u3067\u3092\u3084\u3063\u305f\u3088<br>\u3068\u3044\u3046\u5099\u5fd8\u9332<\/p>\n\n\n\n<h2>\u307e\u305a\u306fwin\u74b0\u5883\u306bk8s\u3092\u5165\u308c\u308b(DockerDesktop\u304b\u3089)<\/h2>\n\n\n\n<p>Docker\u74b0\u5883\u5c0e\u5165\u306f<a href=\"https:\/\/auto.meto4d.pgw.jp\/blog\/?p=95\">\u524d\u8a18\u4e8b(Docker\u74b0\u5883\u3092\u4f5c\u308b)<\/a>\u304b\u3089<br>DockerDesktop\u304b\u3089kubernetes\u5165\u308c\u3089\u308c\u308b\u306e\u306f\u4fbf\u5229\u306d<br>\u3057\u304b\u3082\u8a2d\u5b9a\u304b\u3089Enable Kubernetes\u306b\u30c1\u30a7\u30c3\u30af\u5165\u308c\u308b\u3060\u3051<br>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u305f\u3089\u5de6\u4e0b\u306b\u3088\u304f\u898b\u308bk8s\u306e\u30de\u30fc\u30af\u304c\u5165\u308b<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"592\" src=\"https:\/\/auto.meto4d.pgw.jp\/blog\/wp-content\/uploads\/2021\/04\/image-1024x592.png\" alt=\"\" class=\"wp-image-133\" srcset=\"https:\/\/auto.meto4d.pgw.jp\/blog\/wp-content\/uploads\/2021\/04\/image-1024x592.png 1024w, https:\/\/auto.meto4d.pgw.jp\/blog\/wp-content\/uploads\/2021\/04\/image-300x173.png 300w, https:\/\/auto.meto4d.pgw.jp\/blog\/wp-content\/uploads\/2021\/04\/image-768x444.png 768w, https:\/\/auto.meto4d.pgw.jp\/blog\/wp-content\/uploads\/2021\/04\/image-1200x694.png 1200w, https:\/\/auto.meto4d.pgw.jp\/blog\/wp-content\/uploads\/2021\/04\/image.png 1244w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>\u5c0e\u5165\u3055\u308c\u305f\u3089\u305d\u308c\u3060\u3051\u3067kubectl\u30b3\u30de\u30f3\u30c9\u304c\u4f7f\u3048\u308b\uff08\u3060\u3063\u305f\u306f\u305a\uff08\u66d6\u6627\uff09\uff09<br>\u306f\u308b\u304b\u6614\u306bminikube\u5165\u308c\u3066\u305f\u304b\u3089\u4f7f\u3048\u3066\u305f\u304b\u3082\u3057\u308c\u306a\u3044<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">cmd&gt; kubectl get node\nNAME             STATUS   ROLES    AGE     VERSION\ndocker-desktop   Ready    master   2d11h   v1.19.7<\/pre><\/div>\n\n\n\n<p>docker-desktop\u3068\u3044\u3046node\u304c\u4f5c\u3089\u308c\u308b<br>node\u306bssh\u3067\u304d\u308b\u304b\u306a\u3068\u601d\u3063\u305f\u3051\u3069\u3001\u898b\u77e5\u3089\u306cip\u304c\u632f\u3089\u308c\u3066\u3044\u305f\u306e\u3067\u3001\u308f\u304b\u3089\u306a\u304b\u3063\u305f<br>\u3053\u308c\u306f\u307e\u305f\u4eca\u5ea6\u304b\u306a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">cmd&gt; kubectl describe node docker-desktop | grep -A 2 Address\nAddresses:\n  InternalIP:  192.168.yy.4\n  Hostname:    docker-desktop<\/pre><\/div>\n\n\n\n<h2>docker image\u4f5c\u6210<\/h2>\n\n\n\n<p>\u307e\u305a2\u7a2e\u985e\u306edocker image\u3092\u4f5c\u308b<br><a href=\"https:\/\/auto.meto4d.pgw.jp\/blog\/?p=95\">\u524d\u56de(Docker\u74b0\u5883\u3092\u4f5c\u308b)<\/a>\u306eDocker\u74b0\u5883\u30c6\u30b9\u30c8\u6642\u3068\u540c\u69d8\u3001\u7279\u306b\u3044\u3058\u308b\u90e8\u5206\u306f\u306a\u3057<br>\uff08\u591a\u5c11\u306e\u30d5\u30a9\u30eb\u30c0\u69cb\u6210\u306f\u5909\u3048\u305f\uff09<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;dockerfile&quot;,&quot;mime&quot;:&quot;text\/x-dockerfile&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Dockerfile&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;docker&quot;}\">FROM nginx:alpine\nCOPY nginx\/nginx.conf \/etc\/nginx\/\nCOPY html\/index.html \/usr\/share\/nginx\/html\/<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;htmlmixed&quot;,&quot;mime&quot;:&quot;text\/html&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;HTML - index.html&quot;,&quot;language&quot;:&quot;HTML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;html&quot;}\">&lt;!doctype html&gt;\n&lt;html&gt;\n&lt;body&gt;\n&lt;h1&gt;Hello Nginx on Docker!&lt;\/h1&gt;\nwork on dokcer\n&lt;\/body&gt;\n&lt;\/html&gt;<\/pre><\/div>\n\n\n\n<p>\u3053\u308c\u3067docker image\u3092\u4f5c\u308b<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">cmd&gt; docker build . -t tiny-nginx:0.1\n\u2192tiny-nginx:0.1\u3092\u4f5c\u6210\u3059\u308b\ncmd&gt; docker image ls\nREPOSITORY                           TAG                                                     IMAGE ID       CREATED         SIZE\ntiny-nginx                           0.1                                                     ec5ecaba6758   9 seconds ago   22.6MB\n<\/pre><\/div>\n\n\n\n<p>k8s\u3067\u30c7\u30d7\u30ed\u30a4\u3059\u308b<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;yaml&quot;,&quot;mime&quot;:&quot;text\/x-yaml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;YAML - tiny-nginx.yaml&quot;,&quot;language&quot;:&quot;YAML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;yaml&quot;}\">apiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: nginx-deployment\nspec:\n  selector:\n    matchLabels:\n      app: nginx-label\n  replicas: 2\n  template:\n    metadata:\n      labels:\n        app: nginx-label\n    spec:\n      containers:\n      - name: tnginx\n        image: tiny-nginx:0.1\n        ports:\n        - containerPort: 80\n\n---\napiVersion: v1\nkind: Service\nmetadata:\n  name: nginx-service\nspec:\n  type: ClusterIP\n  selector:\n    app: nginx-label\n  ports:\n  - name: http\n    port: 8080\n    targetPort: 80\n    protocol: TCP<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">cmd&gt; kubectl create ns dev\nnamespace\/dev created\n\u5ff5\u306e\u70banamespace\/dev\u3092\u4f5c\u3063\u3066\u304a\u304f\n&gt; kubectl get svc -n dev\nNAME            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE\nnginx-service   ClusterIP   10.99.233.150   &lt;none&gt;        8080\/TCP   2d11h\n\ncmd&gt; kubectl get pod -n dev\nNAME                                READY   STATUS    RESTARTS   AGE\nnginx-deployment-6465d9766d-6h6wn   1\/1     Running   0          31s\nnginx-deployment-6465d9766d-784ww   1\/1     Running   0          33s\n\ncmd&gt; kubectl exec -n dev nginx-deployment-6465d9766d-6h6wn -- bash\nOCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: &quot;bash&quot;: executable file not found in $PATH: unknown\ncommand terminated with exit code 126\n\u2192bash\u306f\u5165\u3063\u3066\u3044\u306a\u3044\u3088\u3046\u3060\ncmd&gt; kubectl exec -it -n dev nginx-deployment-6465d9766d-6h6wn -- sh\n\/ # nginx -v\nnginx version: nginx\/1.19.10\n\/ # cat \/usr\/share\/nginx\/html\/index.html\n&lt;!doctype html&gt;\n&lt;html&gt;\n&lt;body&gt;\n&lt;h1&gt;Hello Nginx on Docker!&lt;\/h1&gt;\nwork on dokcer\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre><\/div>\n\n\n\n<p>\u3061\u3083\u3093\u3068local\u3067\u4f5c\u6210\u3057\u305fdocker image\u304c\u30c7\u30d7\u30ed\u30a4\u3067\u304d\u3066\u3044\u308b<\/p>\n\n\n\n<p>local\u3067\u30dd\u30fc\u30c8\u958b\u653e\u3059\u308b\u305f\u3081\u306b\u306f<code>kubectl port-forward<\/code>\u3067\u5b9f\u65bd\u3067\u304d\u308b<br><code>kubectl port-forward -n dev nginx-service 80:8080<\/code><br>\u3060\u3068nginx-service\u306epod\u3092\u63a2\u3057\u3066\u3057\u307e\u3046<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;shell&quot;,&quot;mime&quot;:&quot;text\/x-sh&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Shell&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;shell&quot;}\">cmd&gt; kubectl port-forward -n dev service\/nginx-service 80:8080\nForwarding from 127.0.0.1:80 -&gt; 80\nForwarding from [::1]:80 -&gt; 80\n\u25a0\n\u2192input\u304c\u623b\u3089\u305a\u5f85\u53d7\u72b6\u614b\u306b\u306a\u308b<\/pre><\/div>\n\n\n\n<p>localhost\u3078\u63a5\u7d9a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" loading=\"lazy\" width=\"650\" height=\"219\" src=\"https:\/\/auto.meto4d.pgw.jp\/blog\/wp-content\/uploads\/2021\/04\/image-1.png\" alt=\"\" class=\"wp-image-138\" srcset=\"https:\/\/auto.meto4d.pgw.jp\/blog\/wp-content\/uploads\/2021\/04\/image-1.png 650w, https:\/\/auto.meto4d.pgw.jp\/blog\/wp-content\/uploads\/2021\/04\/image-1-300x101.png 300w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<p>\u3061\u3083\u3093\u3068\u3064\u306a\u304c\u3063\u305f<br>cmd\u306b\u306f\u30a2\u30af\u30bb\u30b9\u304c\u6709\u3063\u305f\u6642<code>Handling connection for 80<\/code>\u304c\u8868\u793a\u3055\u308c\u308b<br>\u623b\u308b\u306b\u306fCtrl+C<\/p>\n\n\n\n<h2>\u307e\u3068\u3081<\/h2>\n\n\n\n<p>Docker Desktop for Windows\u3067\u30d3\u30eb\u30c9\u3057\u305fimage\u306f\u3001k8s(Docker Desktop for Windows)\u3067\u76f4\u63a5\u4f7f\u3048\u308b<br>\u306a\u3093\u3066\u3053\u3068\u306f\u306a\u3044\u7c21\u5358\u3060\u3063\u305f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3084\u3070\u3044\u3053\u306e\u307e\u307e\u3058\u3083\u30b3\u30f3\u30c6\u30ca\u958b\u767a\u30de\u30f3\u306b\u306a\u3063\u3066\u3057\u307e\u3046 PHP8\u3092\u8a66\u3057\u305f\u3088\u3068\u304bpython\u5f04\u3063\u305f\u3088\u3068\u304b\u3063\u3066\u8a18\u4e8b\u3092\u66f8\u3053\u3046\u3068\u601d\u3063\u305f\u306e\u306b\u30b3\u30f3\u30c6\u30ca\u306e\u65b9\u3070\u3063\u304b\u308a\u3044\u3058\u3063\u3066\u308b\u6c17\u304c\u3059\u308b<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9,14,7,6,5],"tags":[],"views":1253,"_links":{"self":[{"href":"https:\/\/auto.meto4d.pgw.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/131"}],"collection":[{"href":"https:\/\/auto.meto4d.pgw.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/auto.meto4d.pgw.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/auto.meto4d.pgw.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/auto.meto4d.pgw.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=131"}],"version-history":[{"count":8,"href":"https:\/\/auto.meto4d.pgw.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":243,"href":"https:\/\/auto.meto4d.pgw.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions\/243"}],"wp:attachment":[{"href":"https:\/\/auto.meto4d.pgw.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/auto.meto4d.pgw.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/auto.meto4d.pgw.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}