現在の Swarm アンロックキーを表示する
このステップでは、Docker Swarm の現在の Swarm アンロックキーを表示する方法を学びます。Swarm アンロックキーは、Swarm が再起動された後にそれをアンロックするために使用されます。これは、Swarm への不正アクセスを防止するためのセキュリティ対策です。
まず、Docker Swarm を初期化する必要があります。docker swarm init
コマンドを使用します。このコマンドは、新しい Swarm を初期化し、現在のノードをマネージャーノードにします。
docker swarm init
Swarm が初期化されたことを示す、以下のような出力が表示されるはずです。
Swarm initialized: current node (xxxxxxxxxxxx) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 192.168.1.100:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
これで Swarm が初期化されたので、docker swarm unlock-key
コマンドを使用して現在の Swarm アンロックキーを表示できます。
docker swarm unlock-key
このコマンドは、現在の Swarm アンロックキーを出力します。それは長い文字列のように見えます。
Swarm unlock key: SWMKEY-1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
このキーは、再起動後に Swarm をアンロックするために必要であるため、安全に保管してください。