0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【docker】compose.yamlから別のYAMLを読み込む方法

0
Last updated at Posted at 2023-09-21

Docker compose v2.20 にてYAMLファイルでincludeのサポートが開始

Docker compose v2.20にてYAMLファイルから別のYAMLファイルを読み込むことができるようになりました。(ちなみにDocker Desktopは4.22からだそうです)

今回はこのinclude機能を試してみます。

設定サンプル(in YAML)

.
├── compose.yaml
└── service_b
    └── compose.yaml
compose.yaml
include:
  - ./service_b/compose.yaml

services:
  service_a:
    image: busybox
    depends_on:
      - service_b
./service_b/compose.yaml
services:
  service_b:
    image: busybox

上記は、./service_b/compose.yamlで読み込んだservice_bが起動してからservice_aを起動する設定です。

まとめ

include機能により、DBコンテナを別で立ち上げたい、公式のYAMLをそのまま使いたいなど、多様なニーズに対応できるようになりました。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?