{"id":30648,"date":"2024-03-27T09:02:31","date_gmt":"2024-03-27T00:02:31","guid":{"rendered":"https:\/\/www.agent-grow.com\/self20percent\/?p=30648"},"modified":"2024-03-27T09:02:33","modified_gmt":"2024-03-27T00:02:33","slug":"docker-image-build%e3%81%a7-pulltrue%e3%81%a7%e3%82%a4%e3%83%a1%e3%83%bc%e3%82%b8%e3%81%ae%e5%86%8d%e5%8f%96%e5%be%97%e3%82%92%e3%81%97%e3%81%a6%e3%82%82%e3%82%b3%e3%83%b3%e3%83%86%e3%82%ad%e3%82%b9","status":"publish","type":"post","link":"https:\/\/www.agent-grow.com\/self20percent\/2024\/03\/27\/docker-image-build%e3%81%a7-pulltrue%e3%81%a7%e3%82%a4%e3%83%a1%e3%83%bc%e3%82%b8%e3%81%ae%e5%86%8d%e5%8f%96%e5%be%97%e3%82%92%e3%81%97%e3%81%a6%e3%82%82%e3%82%b3%e3%83%b3%e3%83%86%e3%82%ad%e3%82%b9\/","title":{"rendered":"docker image build\u3067&#8211;pull=true\u3067\u30a4\u30e1\u30fc\u30b8\u306e\u518d\u53d6\u5f97\u3092\u3057\u3066\u3082\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u304c\u66f4\u65b0\u3055\u308c\u306a\u3044\u554f\u984c"},"content":{"rendered":"<p>\u984c\u76ee\u306e\u901a\u308a\u300cdocker image build\u3067&#8211;pull=true\u3067\u30a4\u30e1\u30fc\u30b8\u306e\u518d\u53d6\u5f97\u3092\u3057\u3066\u3082\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u304c\u66f4\u65b0\u3055\u308c\u306a\u3044\u554f\u984c\u300d\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u89e3\u6d88\u6cd5\u306b\u3064\u3044\u3066\u5099\u5fd8\u9332\u3068\u3057\u3066\u307e\u3068\u3081\u307e\u3059\u3002<\/p>\n<h2>\u7d50\u8ad6<\/h2>\n<p>\u3044\u304d\u306a\u308a\u7d50\u8ad6\u3092\u66f8\u304d\u307e\u3059\u304c\u3001\u306a\u3093\u3068\u306a\u304f\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u554f\u984c\u304b\u306a\uff1f\u3068\u601d\u3063\u305f\u3089\u30ad\u30e3\u30c3\u30b7\u30e5\u306e\u554f\u984c\u3067\u3057\u305f\u3002<\/p>\n<p>\u4e00\u5ea6\u65e2\u306b\u4f5c\u6210\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u3092\u524a\u9664\u3057\u305f\u3046\u3048\u3067\u3001\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u7121\u52b9\u306b\u3057\u3066<code>docker imge build<\/code>\u3092\u5b9f\u884c\u3059\u308b\u969b\u306b<code>--no-cache<\/code>\u3092\u6307\u5b9a\u3057\u3066\u5b9f\u884c\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>\u30a4\u30e1\u30fc\u30b8\u306e\u518d\u53d6\u5f97\u3067\u3044\u3051\u308b\u3068\u52d8\u9055\u3044<\/h2>\n<p>\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb (\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u5b9f\u884c\u3059\u308b\u30d5\u30a1\u30a4\u30eb)\u306b\u30bf\u30a4\u30dd\u304c\u3042\u308a\u3001\u305d\u306e\u5185\u5bb9\u3092\u4fee\u6b63\u3057\u3066<code>docker image build --pull=true<\/code>\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u3059\u3067\u306b\u4f5c\u6210\u3055\u308c\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u30a4\u30e1\u30fc\u30b8\u306e\u518d\u53d6\u5f97\u3092\u884c\u3046\u3053\u3068\u3067\u3001Dockerfile\u306b\u8a18\u8ff0\u3057\u305fCOPY\u306e\u5185\u5bb9\u304c\u30b3\u30f3\u30c6\u30ca\u5185\u306b\u66f4\u65b0\u3055\u308c\u308b\u3068\u601d\u3063\u3066\u304a\u308a\u307e\u3057\u305f\u304c\u3001\u4f55\u5ea6\u3084\u3063\u3066\u3082\u66f4\u65b0\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<h5>\u30bf\u30a4\u30dd\u3057\u3066\u3044\u305f\u5185\u5bb9<\/h5>\n<p>\u8aa4\u3063\u305f\u8a18\u8ff0<\/p>\n<pre>#! \/bin\/bash\necho \"[`date`]\" Hello!\"<\/pre>\n<p>\u6b63\u3057\u3044\u8a18\u8ff0<\/p>\n<pre>#! \/bin\/bash\necho \"[`date`] Hello!\"\n\n<\/pre>\n<p>\u300c&#8221;\u300d\u306e\u4f4d\u7f6e\u3092\u9593\u9055\u3048\u3066\u307e\u3059\u3002<\/p>\n<p><code>docker image build --pull=true<\/code>\u3067\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u3066\u3001<code>docker container exec -it \u30b3\u30f3\u30c6\u30ca\u540d bash<\/code>\u3067\u30b3\u30f3\u30c6\u30ca\u5185\u306b\u5165\u3063\u3066\u30d5\u30a1\u30a4\u30eb\u306e\u4e2d\u8eab\u3092<code>cat<\/code>\u3059\u308b\u3082\u66f4\u65b0\u3055\u308c\u3066\u3044\u306a\u3044\u3002<\/p>\n<p>\u3088\u304f\u898b\u308b\u3068\u521d\u56de\u306e<code>docker image build<\/code>\u30682\u56de\u76ee\u4ee5\u964d\u306e<code>docker image build --pull=true<\/code>\u306e\u5b9f\u884c\u7d50\u679c\u3092\u898b\u6bd4\u3079\u3066\u307f\u308b\u3068\u3001\u3061\u3083\u3093\u3068\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u3066\u3044\u308b\u3088\u3068\u3044\u3046\u306e\u304c\u30bf\u30fc\u30df\u30ca\u30eb\u306b\u8868\u793a\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<h5>\u521d\u56de\u5b9f\u884c\u6642\u306ebuild\u306e\u7d50\u679c<\/h5>\n<pre>$ docker image build -t ch03\/cronjob:latest .\n[+] Building 106.6s (11\/11) FINISHED\n=&gt; [internal] load build definition from Dockerfile 0.1s\n=&gt; =&gt; transferring dockerfile: 217B 0.0s\n=&gt; [internal] load metadata for docker.io\/library\/ubuntu:23.10 0.0s\n=&gt; [internal] load .dockerignore 0.0s\n=&gt; =&gt; transferring context: 2B 0.0s\n=&gt; [1\/6] FROM docker.io\/library\/ubuntu:23.10 0.0s\n=&gt; [internal] load build context 0.2s\n=&gt; =&gt; transferring context: 169B 0.0s\n=&gt; [2\/6] RUN apt update 100.2s\n=&gt; [3\/6] RUN apt install -y cron 4.9s\n=&gt; [4\/6] COPY task.sh \/usr\/local\/bin\/ 0.1s\n=&gt; [5\/6] COPY cron-example \/etc\/cron.d\/ 0.1s\n=&gt; [6\/6] RUN chmod 0644 \/etc\/cron.d\/cron-example 0.3s\n=&gt; exporting to image 0.4s\n=&gt; =&gt; exporting layers 0.3s\n=&gt; =&gt; writing image sha256:49181069a33be78630d00de3116c56180d139386aac43689817d219de396ca09 0.0s\n=&gt; =&gt; naming to docker.io\/ch03\/cronjob:latest<\/pre>\n<h5>2\u56de\u76ee\u4ee5\u964d\u306ebuild\u306e\u7d50\u679c<\/h5>\n<pre>docker image build --pull=true -t ch03\/cronjob:latest .\n=&gt; [internal] load build definition from Dockerfile 0.0s\n=&gt; =&gt; transferring dockerfile: 217B 0.0s\n=&gt; [internal] load metadata for docker.io\/library\/ubuntu:23.10 0.0s\n=&gt; [internal] load .dockerignore 0.0s\n=&gt; =&gt; transferring context: 2B 0.0s\n=&gt; [1\/6] FROM docker.io\/library\/ubuntu:23.10 0.0s\n=&gt; [internal] load build context 0.0s\n=&gt; =&gt; transferring context: 59B 0.0s\n=&gt; <mark>CACHED<\/mark> [2\/6] RUN apt update 0.0s\n=&gt; <mark>CACHED<\/mark> [3\/6] RUN apt install -y cron 0.0s\n=&gt; <mark>CACHED<\/mark> [4\/6] COPY task.sh \/usr\/local\/bin\/ 0.0s\n=&gt; <mark>CACHED<\/mark> [5\/6] COPY cron-example \/etc\/cron.d\/ 0.0s\n=&gt; <mark>CACHED<\/mark> [6\/6] RUN chmod 0644 \/etc\/cron.d\/cron-example 0.0s\n=&gt; exporting to image 0.0s\n=&gt; =&gt; exporting layers 0.0s\n=&gt; =&gt; writing image sha256:51ff3f95463003901f28dec9f4ba9b3a576ab7d4b0303ad8d6d2318331ba8070 0.0s\n=&gt; =&gt; naming to docker.io\/ch03\/cronjob:latest<\/pre>\n<p>\u5b9f\u884c\u6642\u9593\u306b\u304a\u3044\u3066\u3082CACHED\u3055\u308c\u3066\u3044\u308b\u306e\u30670.0s\u30680\u79d2\u3067\u7d42\u4e86\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u5f53\u7136\u30ad\u30e3\u30c3\u30b7\u30e5\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001<\/p>\n<pre>$ docker container exec -it cronjob bash\nroot@a72dace5042a:\/# cat \/usr\/local\/bin\/task.sh \n#! \/bin\/bash\necho \"[`date`]\" Hello!\"<\/pre>\n<p>\u307e\u3060\u30bf\u30a4\u30dd\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u7121\u52b9\u5316\u3057\u3066\u5b9f\u884c\u3059\u308b<\/h2>\n<p>\u4e00\u65e6\u3001<code>docker image rm<\/code> \u3067\u30a4\u30e1\u30fc\u30b8\u3092\u524a\u9664\u3057\u3001\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u7121\u52b9\u5316\u3057\u3066<code>build<\/code>\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>$ docker image build --no-cache -t ch03\/cronjob:latest .\n[+] Building 29.6s (11\/11) FINISHED docker:default\n=&gt; [internal] load build definition from Dockerfile 0.0s\n=&gt; =&gt; transferring dockerfile: 217B 0.0s\n=&gt; [internal] load metadata for docker.io\/library\/ubuntu:23.10 2.7s\n=&gt; [internal] load .dockerignore 0.0s\n=&gt; =&gt; transferring context: 2B 0.0s\n=&gt; CACHED [1\/6] FROM docker.io\/library\/ubuntu:23.10@sha256:5cd569b792a8b7b483d90942381cd7e0b03f0a15520d6e23fb7a1464a25a71b1 0.0s\n=&gt; =&gt; resolve docker.io\/library\/ubuntu:23.10@sha256:5cd569b792a8b7b483d90942381cd7e0b03f0a15520d6e23fb7a1464a25a71b1 0.0s\n=&gt; [internal] load build context 0.0s\n=&gt; =&gt; transferring context: 59B 0.0s\n=&gt; [2\/6] RUN apt update 20.8s\n=&gt; [3\/6] RUN apt install -y cron 4.9s\n=&gt; [4\/6] COPY task.sh \/usr\/local\/bin\/ 0.1s \n=&gt; [5\/6] COPY cron-example \/etc\/cron.d\/ 0.1s \n=&gt; [6\/6] RUN chmod 0644 \/etc\/cron.d\/cron-example 0.3s \n=&gt; exporting to image 0.4s \n=&gt; =&gt; exporting layers 0.3s \n=&gt; =&gt; writing image sha256:327b21f2be4e21f3991fedb7a17ab2a974b9b54e8fb0bfad25d0fdd0d05519a9 0.0s\n=&gt; =&gt; naming to docker.io\/ch03\/cronjob:latest<\/pre>\n<p>\u4e0a\u8a18\u304c\u5b9f\u884c\u7d50\u679c\u3067\u3059\u304c\u3001\u4eca\u5ea6\u306fRUN\u4ee5\u964d\u306e\u5b9f\u884c\u304c<code>CACHED<\/code>\u3055\u308c\u305a\u306b\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\u30bf\u30a4\u30dd\u304c\u89e3\u6d88\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<pre>root@a72dace5042a:\/# cat usr\/local\/bin\/task.sh \n#! \/bin\/bash\necho \"[`date`]\" Hello!\"<\/pre>\n<p>\u4eca\u5f8c\u30ad\u30e3\u30c3\u30b7\u30e5\u3067\u306f\u307e\u3089\u306a\u3044\u305f\u3081\u306e\u5099\u5fd8\u9332\u3067\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u984c\u76ee\u306e\u901a\u308a\u300cdocker image build\u3067&#8211;pull=true\u3067\u30a4\u30e1\u30fc\u30b8\u306e\u518d\u53d6\u5f97\u3092\u3057\u3066\u3082\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u304c\u66f4\u65b0\u3055\u308c\u306a\u3044\u554f\u984c\u300d\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u89e3\u6d88\u6cd5\u306b\u3064\u3044\u3066\u5099\u5fd8\u9332\u3068\u3057\u3066\u307e\u3068\u3081\u307e\u3059\u3002 \u7d50\u8ad6 \u3044\u304d\u306a [&hellip;]<\/p>\n","protected":false},"author":82,"featured_media":30649,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10],"tags":[901,902],"class_list":["post-30648","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-docker","tag-dockerfile"],"jetpack_featured_media_url":"https:\/\/www.agent-grow.com\/self20percent\/wp-content\/uploads\/2024\/03\/e9d3b3c5bd4a3c76d17e31ff68fd8d01.png","jetpack_shortlink":"https:\/\/wp.me\/p7Bq4F-7Yk","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/posts\/30648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/users\/82"}],"replies":[{"embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/comments?post=30648"}],"version-history":[{"count":0,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/posts\/30648\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/media\/30649"}],"wp:attachment":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/media?parent=30648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/categories?post=30648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/tags?post=30648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}