{"id":549,"date":"2025-08-21T13:51:00","date_gmt":"2025-08-21T04:51:00","guid":{"rendered":"https:\/\/sejiwon.com\/?p=549"},"modified":"2025-08-21T14:08:10","modified_gmt":"2025-08-21T05:08:10","slug":"docker-buildx-build-%eb%aa%85%eb%a0%b9%ec%96%b4","status":"publish","type":"post","link":"https:\/\/sejiwon.com\/?p=549","title":{"rendered":"docker buildx build \uba85\ub839\uc5b4"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\ud83d\udccc \uc124\uba85<\/h2>\n\n\n\n<ul>\n<li><code>docker buildx build<\/code>\ub294 BuildKit\uc744 \uc0ac\uc6a9\ud574 \uc774\ubbf8\uc9c0\ub97c \ube4c\ub4dc\ud569\ub2c8\ub2e4.<\/li>\n\n\n\n<li><code>docker build<\/code>, <code>docker image build<\/code> \ub4f1\uc758 \uba85\ub839\uc5b4\uc640 <strong>\ub3d9\uc77c\ud558\uac70\ub098 \uc720\uc0ac\ud558\uac8c \ub3d9\uc791<\/strong>\ud558\uc9c0\ub9cc, \ub354 \ub9ce\uc740 \uae30\ub2a5\uc744 \uc9c0\uc6d0\ud569\ub2c8\ub2e4.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udee0\ufe0f \uae30\ubcf8 \uc0ac\uc6a9\ubc95<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>docker buildx build &#91;OPTIONS] PATH | URL | -\n<\/code><\/pre>\n\n\n\n<ul>\n<li><code>PATH<\/code>: Dockerfile\uc774 \uc788\ub294 \ub514\ub809\ud130\ub9ac<\/li>\n\n\n\n<li><code>URL<\/code>: \uc6d0\uaca9 Git \ub9ac\ud3ec\uc9c0\ud1a0\ub9ac \ub4f1<\/li>\n\n\n\n<li><code>-<\/code>: \ud45c\uc900 \uc785\ub825<\/li>\n<\/ul>\n\n\n\n<p>\uc608\uc2dc:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker buildx build -t my-image:latest .\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2699\ufe0f \uc8fc\uc694 \uc635\uc158 (\ud55c\uae00 \uc124\uba85 \ud3ec\ud568)<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\uc635\uc158<\/th><th>\uc124\uba85<\/th><\/tr><\/thead><tbody><tr><td><code>--add-host<\/code><\/td><td>\ucee8\ud14c\uc774\ub108 <code>\/etc\/hosts<\/code>\uc5d0 \ud638\uc2a4\ud2b8-IP \ub9e4\ud551 \ucd94\uac00<\/td><\/tr><tr><td><code>--allow<\/code><\/td><td>\uace0\uae09 \uad8c\ud55c \ud5c8\uc6a9 (\uc608: <code>network.host<\/code>, <code>security.insecure<\/code>)<\/td><\/tr><tr><td><code>--annotation<\/code><\/td><td>\uc774\ubbf8\uc9c0\uc5d0 \uc8fc\uc11d(Annotation) \ucd94\uac00<\/td><\/tr><tr><td><code>--attest<\/code><\/td><td>SBOM, provenance \ub4f1 \uc774\ubbf8\uc9c0 \uac80\uc99d \uc815\ubcf4 \ud3ec\ud568<\/td><\/tr><tr><td><code>--build-arg<\/code><\/td><td>\ube4c\ub4dc \uc2dc\uac04\uc5d0 \uc0ac\uc6a9\ud560 \uc778\uc790 \ubcc0\uc218 \uc124\uc815<\/td><\/tr><tr><td><code>--cache-from<\/code> \/ <code>--cache-to<\/code><\/td><td>\ube4c\ub4dc \uce90\uc2dc \uacbd\ub85c \uc9c0\uc815 (\uc131\ub2a5 \ucd5c\uc801\ud654)<\/td><\/tr><tr><td><code>--file<\/code> \ub610\ub294 <code>-f<\/code><\/td><td>\uc0ac\uc6a9\ud560 Dockerfile \uc9c0\uc815 (\uae30\ubcf8\uac12: <code>.\/Dockerfile<\/code>)<\/td><\/tr><tr><td><code>--iidfile<\/code><\/td><td>\ube4c\ub4dc\ub41c \uc774\ubbf8\uc9c0 ID\ub97c \ud30c\uc77c\uc5d0 \uc800\uc7a5<\/td><\/tr><tr><td><code>--label<\/code><\/td><td>\uc774\ubbf8\uc9c0\uc5d0 \uba54\ud0c0\ub370\uc774\ud130 \ub77c\ubca8 \ucd94\uac00<\/td><\/tr><tr><td><code>--load<\/code><\/td><td>\uc774\ubbf8\uc9c0 \uacb0\uacfc\ub97c \ub85c\uceec Docker\uc5d0 \ubc14\ub85c \ub85c\ub4dc (<code>docker image ls<\/code>\uc5d0\uc11c \ubc14\ub85c \ubcf4\uc784)<\/td><\/tr><tr><td><code>--push<\/code><\/td><td>\uc774\ubbf8\uc9c0 \uacb0\uacfc\ub97c \ub808\uc9c0\uc2a4\ud2b8\ub9ac\uc5d0 \ud478\uc2dc<\/td><\/tr><tr><td><code>--output<\/code>, <code>-o<\/code><\/td><td>\ube4c\ub4dc \uacb0\uacfc \ucd9c\ub825 \uacbd\ub85c \uc9c0\uc815 (<code>type=local<\/code>, <code>type=docker<\/code>, <code>type=registry<\/code>)<\/td><\/tr><tr><td><code>--platform<\/code><\/td><td>\ub300\uc0c1 \ud50c\ub7ab\ud3fc \uc9c0\uc815 (\uc608: <code>linux\/amd64<\/code>, <code>linux\/arm64<\/code>)<\/td><\/tr><tr><td><code>--progress<\/code><\/td><td>\ube4c\ub4dc \ucd9c\ub825 \ud615\uc2dd \uc9c0\uc815 (<code>auto<\/code>, <code>plain<\/code>, <code>quiet<\/code>, \ub4f1)<\/td><\/tr><tr><td><code>--pull<\/code><\/td><td>\ucc38\uc870\ub41c \ubaa8\ub4e0 \uc774\ubbf8\uc9c0\ub97c \uac15\uc81c\ub85c pull<\/td><\/tr><tr><td><code>--secret<\/code><\/td><td>\ube4c\ub4dc \uc911 \uc0ac\uc6a9\ud560 \ubcf4\uc548 \uc815\ubcf4 \uc804\ub2ec<\/td><\/tr><tr><td><code>--ssh<\/code><\/td><td>SSH \ud0a4 \uc804\ub2ec<\/td><\/tr><tr><td><code>--tag<\/code>, <code>-t<\/code><\/td><td>\ube4c\ub4dc \uacb0\uacfc \uc774\ubbf8\uc9c0\uc5d0 \ud0dc\uadf8 \uc9c0\uc815<\/td><\/tr><tr><td><code>--target<\/code><\/td><td>\uba40\ud2f0\uc2a4\ud14c\uc774\uc9c0 \ube4c\ub4dc \uc2dc \ud2b9\uc815 \uc2a4\ud14c\uc774\uc9c0\ub9cc \ube4c\ub4dc<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udca1 \uc608\uc2dc: <code>\/etc\/hosts<\/code>\uc5d0 \ud638\uc2a4\ud2b8 \ucd94\uac00<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>docker buildx build --add-host my_hostname=8.8.8.8 .\ndocker buildx build --add-host host.docker.internal=host-gateway .\ndocker buildx build --add-host my-hostname_v6=&#91;2001:4860:4860::8888] .\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2705 \uc608\uc2dc: \uc2e4\uc804 \ube4c\ub4dc \uba85\ub839<\/h2>\n\n\n\n<ol>\n<li>\ub85c\uceec\uc5d0\uc11c Dockerfile\ub85c \ube4c\ub4dc:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>docker buildx build -t my-app:latest .\n<\/code><\/pre>\n\n\n\n<ol start=\"2\">\n<li>\uba40\ud2f0 \ud50c\ub7ab\ud3fc \uc774\ubbf8\uc9c0 \ube4c\ub4dc \ud6c4 \ud478\uc2dc:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>docker buildx build --platform linux\/amd64,linux\/arm64 -t myrepo\/myapp:latest --push .\n<\/code><\/pre>\n\n\n\n<ol start=\"3\">\n<li>\uce90\uc2dc\ub97c \uc0ac\uc6a9\ud558\uc5ec \ube60\ub974\uac8c \ube4c\ub4dc:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>docker buildx build --cache-from=type=local,src=.\/cache --cache-to=type=local,dest=.\/cache .\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc \uc694\uc57d<\/h2>\n\n\n\n<ul>\n<li><code>buildx<\/code>\ub294 <strong>\uace0\uae09 \ube4c\ub4dc \uae30\ub2a5<\/strong>\uc744 \uc0ac\uc6a9\ud558\ub294 \ub3c4\uad6c\ub85c, \uba40\ud2f0\ud50c\ub7ab\ud3fc, \uce90\uc2dc, \ud478\uc2dc\/\ub85c\ub4dc \ub4f1 \ub2e4\uc591\ud55c \uae30\ub2a5\uc744 \uc81c\uacf5\ud569\ub2c8\ub2e4.<\/li>\n\n\n\n<li><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc 1. <code>--annotation<\/code><\/h2>\n\n\n\n<p><strong>\uc774\ubbf8\uc9c0\uc5d0 \uc8fc\uc11d(\uba54\ud0c0\ub370\uc774\ud130)\uc744 \ucd94\uac00<\/strong>\ud569\ub2c8\ub2e4.<br>OCI(Open Container Initiative) \ud615\uc2dd\uc73c\ub85c \ucd94\uac00\ub418\uba70, \uc0ac\uc6a9 \uc704\uce58(\ub808\ubca8)\ub97c \uc9c0\uc815\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 \uae30\ubcf8 \ud615\uc2dd<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>--annotation \"key=value\"\n--annotation \"&#91;type:]key=value\"\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 \uc608\uc2dc<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \uae30\ubcf8 (manifest\uc5d0 \ucd94\uac00\ub428)\ndocker buildx build -t myimage --annotation \"foo=bar\" --push .\n\n# image index\uc5d0 \ucd94\uac00\ndocker buildx build -t myimage --annotation \"index:foo=bar\" --push .\n\n# \uc5ec\ub7ec \ub808\ubca8\uc5d0 \ub3d9\uc2dc\uc5d0 \ucd94\uac00\ndocker buildx build -t myimage --annotation \"index,manifest,manifest-descriptor:foo=bar\" --push .\n\n# \ud2b9\uc815 \ud50c\ub7ab\ud3fc\uc5d0\ub9cc \ucd94\uac00\ndocker buildx build -t myimage --annotation \"manifest&#91;linux\/amd64]:foo=bar\" --push .\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u2757\uc8fc\uc758<\/h3>\n\n\n\n<ul>\n<li><code>manifest[linux\/*]<\/code> \uc640 \uac19\uc740 \uc640\uc77c\ub4dc\uce74\ub4dc\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc 2. <code>--attest<\/code><\/h2>\n\n\n\n<p><strong>\uc774\ubbf8\uc9c0 \ube4c\ub4dc \uacb0\uacfc\uc5d0 \ub300\ud55c \uc99d\uba85(Attestation)\uc744 \uc0dd\uc131<\/strong>\ud569\ub2c8\ub2e4.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 \uc8fc\uc694 \ud0c0\uc785<\/h3>\n\n\n\n<ul>\n<li><code>sbom<\/code>: Software Bill of Materials (\uad6c\uc131 \uc694\uc18c \ubaa9\ub85d)<\/li>\n\n\n\n<li><code>provenance<\/code>: \ube4c\ub4dc \ucd9c\ucc98\/\uacfc\uc815 \uc99d\uba85 (SLSA Provenance)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 \uc0ac\uc6a9 \uc608\uc2dc<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># SBOM \ucd94\uac00\ndocker buildx build --attest=type=sbom --push .\n\n# Provenance \ucd94\uac00\ndocker buildx build --attest=type=provenance --push .\n\n# \ucd95\uc57d\ud615\ndocker buildx build --sbom --provenance --push .\n<\/code><\/pre>\n\n\n\n<p>\ud83d\udccc <strong>Attestation\uc740 \uc774\ubbf8\uc9c0\ub97c \ud478\uc2dc\ud560 \ub54c\ub9cc \uc801\uc6a9<\/strong>\ub429\ub2c8\ub2e4.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc 3. <code>--allow<\/code><\/h2>\n\n\n\n<p><strong>BuildKit \uc2e4\ud589 \uad8c\ud55c \ud655\uc7a5 (\uc704\ud5d8\ud55c \uae30\ub2a5 \ud65c\uc131\ud654)<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 \uc8fc\uc694 \uad8c\ud55c<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\uad8c\ud55c<\/th><th>\uc124\uba85<\/th><\/tr><\/thead><tbody><tr><td><code>network.host<\/code><\/td><td>\ucee8\ud14c\uc774\ub108\uac00 \ud638\uc2a4\ud2b8 \ub124\ud2b8\uc6cc\ud06c\ub97c \uc0ac\uc6a9 \uac00\ub2a5<\/td><\/tr><tr><td><code>security.insecure<\/code><\/td><td>\uc0cc\ub4dc\ubc15\uc2a4 \uc5c6\uc774 \uc2e4\ud589 \ud5c8\uc6a9 (\ubcf4\uc548\uc5d0 \ucde8\uc57d\ud568)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 \uc0ac\uc6a9 \uc608\uc2dc<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \ube4c\ub354 \uc0dd\uc131 \uc2dc \uad8c\ud55c \ud5c8\uc6a9\ndocker buildx create --name insecure-builder --use --buildkitd-flags '--allow-insecure-entitlement security.insecure'\n\n# \ube4c\ub4dc \uc2dc \uad8c\ud55c \uc0ac\uc6a9\ndocker buildx build --allow security.insecure .\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc 4. <code>--build-arg<\/code><\/h2>\n\n\n\n<p><strong>\ube4c\ub4dc \uc2dc \ubcc0\uc218 \uc804\ub2ec (<code>ARG<\/code> \uba85\ub839\uc5b4\uc640 \ud568\uaed8 \uc0ac\uc6a9)<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 \uc608\uc2dc<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \uc9c1\uc811 \uac12 \uc9c0\uc815\ndocker buildx build --build-arg VERSION=1.2.3 .\n\n# \ud658\uacbd \ubcc0\uc218\uc5d0\uc11c \uac12 \uc804\ub2ec\nexport API_KEY=abc123\ndocker buildx build --build-arg API_KEY .\n<\/code><\/pre>\n\n\n\n<p>Dockerfile \uc608\uc2dc:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ARG VERSION\nRUN echo \"Version is $VERSION\"\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 \uc790\uc8fc \uc0ac\uc6a9\ud558\ub294 \ub0b4\uc7a5 \uc778\uc790<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\uc778\uc790<\/th><th>\uc124\uba85<\/th><\/tr><\/thead><tbody><tr><td><code>BUILDKIT_CONTEXT_KEEP_GIT_DIR=1<\/code><\/td><td><code>.git<\/code> \ub514\ub809\ud130\ub9ac \uc720\uc9c0<\/td><\/tr><tr><td><code>BUILDKIT_INLINE_CACHE=1<\/code><\/td><td>\uce90\uc2dc \uba54\ud0c0\ub370\uc774\ud130 \ud3ec\ud568<\/td><\/tr><tr><td><code>BUILDKIT_MULTI_PLATFORM=1<\/code><\/td><td>\uba40\ud2f0 \ud50c\ub7ab\ud3fc \ucd9c\ub825 \ubcf4\uc7a5<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udce6 \uc694\uc57d<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\uc635\uc158<\/th><th>\uc6a9\ub3c4<\/th><\/tr><\/thead><tbody><tr><td><code>--annotation<\/code><\/td><td>\uc774\ubbf8\uc9c0\uc5d0 \uc124\uba85\/\uba54\ud0c0\ub370\uc774\ud130 \ucd94\uac00<\/td><\/tr><tr><td><code>--attest<\/code><\/td><td>\uc774\ubbf8\uc9c0\uc5d0 \ubcf4\uc548\/\ucd9c\ucc98 \uc99d\uba85 \ucca8\ubd80 (SBOM, provenance)<\/td><\/tr><tr><td><code>--allow<\/code><\/td><td>\uc704\ud5d8\ud55c \uae30\ub2a5 (host network, sandbox \ud574\uc81c \ub4f1) \ud5c8\uc6a9<\/td><\/tr><tr><td><code>--build-arg<\/code><\/td><td>\ube4c\ub4dc \uc2dc \uc778\uc790 \ubcc0\uc218 \uc804\ub2ec (Dockerfile\uc758 <code>ARG<\/code> \uc0ac\uc6a9)<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udccc \uc124\uba85 \ud83d\udee0\ufe0f \uae30\ubcf8 \uc0ac\uc6a9\ubc95 \uc608\uc2dc: \u2699\ufe0f \uc8fc\uc694 \uc635\uc158 (\ud55c\uae00 \uc124\uba85 \ud3ec\ud568) \uc635\uc158 \uc124\uba85 &#8211;add-host \ucee8\ud14c\uc774\ub108 \/etc\/hosts\uc5d0 \ud638\uc2a4\ud2b8-IP \ub9e4\ud551 \ucd94\uac00 &#8211;allow \uace0\uae09 \uad8c\ud55c \ud5c8\uc6a9 (\uc608: network.host, security.insecure) &#8211;annotation \uc774\ubbf8\uc9c0\uc5d0 \uc8fc\uc11d(Annotation) \ucd94\uac00 &#8211;attest SBOM, provenance \ub4f1 \uc774\ubbf8\uc9c0 \uac80\uc99d \uc815\ubcf4 \ud3ec\ud568 &#8211;build-arg \ube4c\ub4dc \uc2dc\uac04\uc5d0 \uc0ac\uc6a9\ud560 \uc778\uc790 \ubcc0\uc218 \uc124\uc815 &#8211;cache-from \/ &#8211;cache-to \ube4c\ub4dc \uce90\uc2dc \uacbd\ub85c \uc9c0\uc815 (\uc131\ub2a5 \ucd5c\uc801\ud654)\u2026 <span class=\"read-more\"><a href=\"https:\/\/sejiwon.com\/?p=549\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/posts\/549"}],"collection":[{"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sejiwon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=549"}],"version-history":[{"count":3,"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/posts\/549\/revisions"}],"predecessor-version":[{"id":552,"href":"https:\/\/sejiwon.com\/index.php?rest_route=\/wp\/v2\/posts\/549\/revisions\/552"}],"wp:attachment":[{"href":"https:\/\/sejiwon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sejiwon.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sejiwon.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}