LoginSignup
0
1

More than 1 year has passed since last update.

docker-compose.yml の設定を.envで外出し

Posted at

概要

  • docker-composer.ymlファイル内で使用する定数を.envファイルで外出しする方法をまとめる

参考

方法

  • docker-composer.ymlファイルと同階層に.envファイルを作成して設置する。
  • 例えば下記のように記載すればmailcatcherのポートは.envで定義されているMAILCATCHER_PORTの値で指定されポートフォワーディングされる。

    • docker-compose.yml

      docker-compose.yml
      version: "3.0"
      
      services:
        mailcatcher:
          image: "schickling/mailcatcher:latest"
          ports:
            - ${MAILCATCHER_PORT}:1080
      
    • .env

      MAILCATCHER_PORT=1080
      
  • $ docker-compose up -dで当該のコンテナを建ててhttp://localhost:1080/にアクセスしたところmailcatcherが正常に表示されていた。

参考文献

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