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

More than 1 year has passed since last update.

【Docker】コンテナ内の環境変数を外部ファイルに書く

Posted at

結論

env_fileでファイルを指定する。
環境によって変わるものだけ外部にまとめようかと思ったけど、environmentとは併用できなかったのでenv_fileenvironmentどちらかのみっぽい。

docker-compose.yml
services:
  web:
    env_file:
      - ./env/web.env

中身

web.env
FLASK_APP=flaskr
FLASK_DEBUG=1
API_KEY=abcd1234

確認

コンテナ内でコマンドを実行してweb.envに書いた変数が出ればOK。
exportは環境変数を出力するLinuxのコマンド。

cmd
docker exec -it CONTAINER bash
export
0
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
0
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?