{"id":500,"date":"2023-02-19T16:04:46","date_gmt":"2023-02-19T07:04:46","guid":{"rendered":"https:\/\/hirabay.net\/?p=500"},"modified":"2023-02-19T16:04:50","modified_gmt":"2023-02-19T07:04:50","slug":"%e3%80%90dockerfile%e3%81%ab%e5%a4%89%e6%95%b0%e3%82%92%e6%b8%a1%e3%81%99%e3%80%91arg%e5%ae%9a%e7%be%a9%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9","status":"publish","type":"post","link":"https:\/\/hirabay.net\/?p=500","title":{"rendered":"\u3010Dockerfile\u306b\u5909\u6570\u3092\u6e21\u3059\u3011ARG\u5b9a\u7fa9\u306e\u4f7f\u3044\u65b9"},"content":{"rendered":"\n<p>Docker image\u3092\u4f5c\u308b\u6642\u3001\u307b\u307c\u307b\u307c\u4e2d\u8eab\u304c\u4e00\u7dd2\u3060\u3051\u3068version\u3060\u3051\u9055\u304f\u3066version\u3054\u3068\u306bDockerfile\u3092\u4f5c\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u3002\u3002<\/p>\n\n\n\n<p>\u4f55\u304b\u4fee\u6b63\u3057\u305f\u3044\u3068\u304d\u306b\uff12\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30d6\u30eb\u30e1\u30f3\u30c6\u3059\u308b\u306e\u304c\u5927\u5909\u3060\u3063\u305f\u306e\u3067Dockerfile\u306b\u5909\u6570\u3092\u6e21\u3057\u3066\u52d5\u304d\u3092\u5909\u3048\u3089\u308c\u306a\u3044\u304b\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/c4179872\/public_html\/hirabay.net\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>110<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/c4179872\/public_html\/hirabay.net\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>115<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/c4179872\/public_html\/hirabay.net\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>122<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">\n  <li class=\"first\">\n    <a href=\"#i-0\">\u7d50\u8ad6<\/a>\n  <\/li>\n  <li>\n    <a href=\"#i-1\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/a>\n  <\/li>\n  <li class=\"last\">\n    <a href=\"#i-2\">\u9006\u5f15\u304d\u89e3\u8aac<\/a>\n    <ul class=\"menu_level_1\">\n      <li class=\"first\">\n        <a href=\"#i-3\">\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306e\u8a2d\u5b9a<\/a>\n      <\/li>\n      <li>\n        <a href=\"#i-4\">\u8907\u6570\u306eARG\u3092\u6271\u3046<\/a>\n      <\/li>\n      <li class=\"last\">\n        <a href=\"#i-5\">\uff11\u3064\u306eDockerfile\u3067\u8907\u6570\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210<\/a>\n      <\/li>\n    <\/ul>\n  <\/li>\n<\/ul>\n\n      \n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">\u7d50\u8ad6<\/h2>\n\n\n\n<p><code>ARG<\/code>\u3068\u3044\u3046\u5b9a\u7fa9\u3092\u4f7f\u3048\u3070\u826f\u3044\u3067\u3059\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-1\">\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h2>\n\n\n<p><\/p><div class=\"memo \"><div class=\"memo_ttl dfont\"> \u30dd\u30a4\u30f3\u30c8<\/div>\u30fbDockerfile\u3067\u306f\u300cARG\u300d\u3067\u5909\u6570\u3092\u5b9a\u7fa9\u3059\u308b<br>\n\u30fb\u5909\u6570\u306e\u5c55\u958b\u306f\u300c${\u5909\u6570\u540d}\u300d<br>\n\u30fb\u5909\u6570\u306fdocker build\u6642\u306b\u300c\u2013build-arg\u300d\u3067\u6307\u5b9a\u3059\u308b<\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-dockerfile\" data-file=\"Dockerfile\" data-lang=\"Docker\"><code>ARG JAVA_VERSION\n\nFROM openjdk:${JAVA_VERSION}<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-bash\" data-file=\"\u5b9f\u884c\u30b3\u30de\u30f3\u30c9\" data-lang=\"Bash\"><code>$ docker build --build-arg JAVA_VERSION=11 .<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-2\">\u9006\u5f15\u304d\u89e3\u8aac<\/h2>\n\n\n\n<p>\u3053\u3053\u304b\u3089\u306f<code>ARG<\/code>\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u9006\u5f15\u304d\u3067\u307e\u3068\u3081\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-3\">\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306e\u8a2d\u5b9a<\/h3>\n\n\n\n<p><code>\u5909\u6570\u540d=\u30c7\u30d5\u30a9\u30eb\u30c8\u5024<\/code>\u3067\u8a18\u8ff0\u3059\u308c\u3070OK\uff01<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-dockerfile\" data-file=\"Dockerfile\" data-lang=\"Docker\"><code>ARG JAVA_VERSION=11\n\nFROM openjdk:${JAVA_VERSION}<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">\u8907\u6570\u306eARG\u3092\u6271\u3046<\/h3>\n\n\n\n<p><code>--build-arg<\/code>\u3092\u8907\u6570\u6307\u5b9a\u3059\u308c\u3070OK\uff01<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-dockerfile\" data-file=\"Dockerfile\" data-lang=\"Docker\"><code>ARG JAVA_VERSION\nARG IMAGE_NAME\n\nFROM ${IMAGE_NAME}:${JAVA_VERSION}<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-bash\" data-file=\"\u5b9f\u884c\u30b3\u30de\u30f3\u30c9\" data-lang=\"Bash\"><code>$ docker build --build-arg IMAGE_NAME=openjdk --build-arg JAVA_VERSION=11 .<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-5\">\uff11\u3064\u306eDockerfile\u3067\u8907\u6570\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210<\/h3>\n\n\n\n<p>\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306aDockerfile\u304c\u3042\u308b\u3068\u3057\u307e\u3059<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-dockerfile\" data-file=\"java17\/Dockerfile\" data-lang=\"Docker\"><code>FROM openjdk:17\n\n# COPY, RUN\u306a\u3069\n\nENTRYPOINT [ \"\/entrypoint.sh\" ]<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-dockerfile\" data-file=\"java11\/Dockerfile\" data-lang=\"Docker\"><code>FROM openjdk:11\n\n# COPY, RUN\u306a\u3069\n\nENTRYPOINT [ \"\/entrypoint.sh\" ]<\/code><\/pre><\/div>\n\n\n\n<p>\u30b5\u30f3\u30d7\u30eb\u306a\u306e\u3067\u8a18\u8ff0\u91cf\u304c\u5c11\u306a\u3044\u3067\u3059\u304c\u3001\u5b9f\u52d9\u3067\u4f7f\u3063\u3066\u3044\u308b\u3068\u3082\u3063\u3068\u8907\u96d1\u306a\u5b9a\u7fa9\u306b\u306a\u308a\u304c\u3061\u3067\u3001\u4f55\u304b\u5909\u66f4\u304c\u5fc5\u8981\u306b\u306a\u308b\u3068\u30c0\u30d6\u30eb\u30e1\u30f3\u30c6\u304c\u5fc5\u8981\u306b\u306a\u308b\u306e\u3067\u9762\u5012\u3067\u3059\u3002<\/p>\n\n\n\n<p><code>ARG<\/code>\u3092\u4f7f\u3046\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4e00\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u8907\u6570\u306e\u30a4\u30e1\u30fc\u30b8\u306b\u5bfe\u5fdc\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-dockerfile\" data-file=\"Dockerfile\" data-lang=\"Docker\"><code>ARG JAVA_VERSION=11\n\nFROM openjdk:${JAVA_VERSION}\n\n# COPY, RUN\u306a\u3069\n\nENTRYPOINT [ \"\/entrypoint.sh\" ]<\/code><\/pre><\/div>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-plain\"><code># java11\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u305f\u3044\u6642\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\uff09\n$ docker build .\n\n# java17\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u4f5c\u6210\u3057\u305f\u3044\u6642\n$ docker build --build-arg JAVA_VERSION=17 .<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Docker image\u3092\u4f5c\u308b\u6642\u3001\u307b\u307c\u307b\u307c\u4e2d\u8eab\u304c\u4e00\u7dd2\u3060\u3051\u3068version\u3060\u3051\u9055\u304f\u3066version\u3054\u3068\u306bDockerfile\u3092\u4f5c\u3063\u3066\u3044\u307e\u3057\u305f\u3002\u3002\u3002 \u4f55\u304b\u4fee\u6b63\u3057\u305f\u3044\u3068\u304d\u306b\uff12\u30d5\u30a1\u30a4\u30eb\u3092\u30c0\u30d6\u30eb\u30e1\u30f3\u30c6\u3059\u308b\u306e\u304c\u5927\u5909\u3060\u3063\u305f\u306e\u3067Dock &#8230; <\/p>\n","protected":false},"author":1,"featured_media":502,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[83],"class_list":{"0":"post-500","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-6","8":"tag-docker"},"jetpack_featured_media_url":"https:\/\/hirabay.net\/wp-content\/uploads\/2023\/02\/Gradle-1-1.png","_links":{"self":[{"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/posts\/500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hirabay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=500"}],"version-history":[{"count":2,"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/posts\/500\/revisions"}],"predecessor-version":[{"id":503,"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/posts\/500\/revisions\/503"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hirabay.net\/index.php?rest_route=\/wp\/v2\/media\/502"}],"wp:attachment":[{"href":"https:\/\/hirabay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hirabay.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hirabay.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}