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 exec -it xxx bach のようにインタラクティブオプションをつけて実行/つけないで実行した際の環境変数の違いメモ

Last updated at Posted at 2023-08-06

docker exec -it xxx bach のようにインタラクティブオプションをつけて実行/つけないで実行した際の環境変数の違いメモ

具体的には、
docker exec -it ${ContainerName} bash のように-it(インタラクティブオプション)をつけてからenvを実行した時と、
docker exec ${ContainerName} bash -c envのように-it(インタラクティブオプション)をつけずにenvを実行した時では、環境変数の適用度合いが異なってので何が違うんだろうと思った際のメモ

結論

以下のようにbash起動時の設定を読み込まれるかどうかが環境変数差分に繋がっている様子だった(他にもあるかもしれません)

https://www.wakuwakubank.com/posts/389-linux-bashrc/#index_id4

ログイン時に読み込まれる設定ファイル
読込順 ファイル 概要
1 /etc/profile システムの全ユーザーに適用されます。
2 ~/.bash_profile
~/.bash_login
~/.profile 上のファイルがなければ下のファイルを読み込みます。
ログイン時のみ読み込ませたい設定を記述します。
3 ~/.bashrc bash起動の度に読み込ませたい設定を記述します。
4 /etc/bashrc システム全体の関数、エイリアスの設定が記述されています。

これで大体、環境変数の違いが解消された(他にもあるかもしれません)

参考

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?