Inconsistent `pull_policy` behavior with `docker compose` when combining build and image
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- docker, docker-compose
- 領域
- build-system, devops
調査の方向性
.devcontainer/devcontainer.json と compose.yml を使用し、@devcontainers/cli up --workspace-folder .. で動作を再現します。まず、このエントリーポイントが image と build の両方を定義するサービスをどのように処理するかを追跡し、次に生成された docker compose コマンドを、文書化されている pull_policy の動作と比較します。イメージを pull するかキャッシュ内で見つけるべき場合に、デフォルトのワークフローが db に対して docker compose build を実行しなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
https://docs.docker.com/reference/compose-file/build/#using-build-and-image
https://docs.docker.com/reference/compose-file/services/#image
Using build and image
When Compose is confronted with both a build subsection for a service and an image attribute, it follows the rules defined by the pull_policy attribute.If pull_policy is missing from the service definition, Compose attempts to pull the image first and then builds from source if the image isn't found in the registry or platform cache.
i.e. by default it should pull image from registry/cache before attempting to build when using docker compose up, therefore I expect
.devcontainer/devcontainer.json --- JSON
1
2 {
3 "name": "Repro",
4 "dockerComposeFile": "../compose.yml",
5 "service": "devcontainer",
6 "workspaceFolder": ".",
7 "runServices": [
8 "db"
9 ]
10 }
11
compose.yml --- YAML
1 services:
2 devcontainer:
3 image: mcr.microsoft.com/devcontainers/base:ubuntu
4 volumes:
5 - ../..:/workspaces:cached
6 network_mode: service:db
7 command: sleep infinity
8
9 db:
10 image: postgres:latest
11 build:
12 context: .
13 dockerfile_inline: |
14 FROM postgres:latest
15 restart: unless-stopped
16 volumes:
17 - postgres-data:/var/lib/postgresql/data
18 environment:
19 POSTGRES_PASSWORD: postgres
20 POSTGRES_USER: postgres
21 POSTGRES_DB: postgres
22
23 volumes:
24 postgres-data:
25
(output from git diff)
to not run docker compose build db when running @devcontainers/cli up --workspace-folder .
But it currently runs docker compose --project-name devcontainer-repro -f <abbreviated-path>/devcontainer-repro/compose.yml build db devcontainer
Why this matters:
When trying to prebuild/cache images it is beneficial to have one compose.yml which both defines the image and how to build the image, otherwise you need to split the file in two compose.build.yml and compose.yml. This behavior is inconsistent and confusing.
- 主要言語
- TypeScript
- スター
- 3k
- フォーク
- 461
- 平均マージ
- 18分
- マージ済み PR(30日)
- 5
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
devcontainers/cli のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
devcontainers/cli#1203 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 68/100
devcontainers/cli#1178 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
devcontainers/cli#1308 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
devcontainers/cli#1307 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
devcontainers/cli#1305 ·
devcontainers/cli の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
vercel-labs/just-bash#464 ·
-
looksLikeSlug() is ASCII-only, so non-Latin entity slugs (e.g. Korean) skip exact match and collapse オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
TanStack/tanstack.com#1293 ·