2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

docker compose の "pull" は意味が複数あるっぽい

2
Posted at

小ネタ。

例えばこういう Docker Compose サービス定義があったとして、

compose.yaml
services:

  app:
    build: .

  db:
    image: postgres:latest
Dockerfile
FROM debian:latest

以下のふたつの "pull" は実際に行われることが全然違うっぽい。

$ docker compose pull
$ docker compose build --pull

どう違うのか正確に説明できるだろうか。

自分は知らんかった。

docker compose pull

サービス定義の中で image: で指定されているコンテナイメージを pull する。

Pulls an image associated with a service defined in a compose.yaml file, but does not start containers based on those images
docker compose pull | Docker Docs

冒頭の例の場合、postgres イメージは pull されるけど debian イメージは pull されない。

docker compose build --pull

ビルド時に --pull オプションを付けた場合は、サービス定義の中で build: で指定されている Dockerfile のベースイメージを pull してからビルドする。

pull requires the image builder to pull referenced images (FROM Dockerfile directive), even if those are already available in the local image store.
Compose Build Specification | Docker Docs

冒頭の例の場合、debian イメージは pull されるけど postgres イメージは pull されない。

すべて更新したい場合

どちらも更新したい場合はふたつ実行するしかなさそう。

$ docker compose pull && docker compose build --pull
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?