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 3 years have passed since last update.

DockerfileでローカルPCの環境変数を利用する。。。ことはできないっぽい

Posted at

っぽいのだけど、docker-compose.ymlに書くことはできる

利用方法

  • AWS_ACCESS_KEY_ID: "${AWS_ACCESS_KEY_ID}"のように書く
  • ローカルの環境変数を定義しておく

export AWS_ACCESS_KEY_ID=AAA

書き方

docker-compose.yml
version: '3' # composeファイルのバーション指定                                                    
services:
  server: # service名
    build: ./server/ # ビルドに使用するDockerfileがあるディレクトリ指定
    environment: 
      AWS_ACCESS_KEY_ID: "${AWS_ACCESS_KEY_ID}"
      AWS_SECRET_ACCESS_KEY: "${AWS_SECRET_ACCESS_KEY}"
    ports: 
      - "8080:8080"
    tty: true # コンテナの起動永続化
    volumes:
      - .:/go/src/work # マウントディレクトリ指定

確認

yuta:~ $ docker exec -it a9f8b66d9a6f echo $AWS_ACCESS_KEY_ID
AAA
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?