LoginSignup
0
0

More than 3 years have passed since last update.

AWSへDockerホストのプロビジョニングをする際にcredentialsがない旨のエラーが表示される

Posted at

AWSへDockerホストのプロビジョニングをする際に、アクセスキーやシークレットキーを記述したcredentialsファイルを作成して、AWSにDocker Engineが動作するインスタンス作成するコマンドを実行したところ、下記エラーが出力されました。

$ docker-machine create --driver amazonec2 --amazonec2-open-port 8000 --amazonec2-region ap-northeast-1 aws-sandbox
Error setting machine configuration from flags provided: amazonec2 driver requires AWS credentials configured with the --amazonec2-access-key and --amazonec2-secret-key options, environment variables, ~/.aws/credentials, or an instance role

これはcredentialsのファイルがないか、もしくは作成する権限がおかしいことを意味するエラーの模様。
AWSで作成したIAMユーザの権限はadmin権限を渡しているので特に問題がないため、credentialsファイルがどうやら悪さしているみたいです。

対策

調べたところ、credentialsファイルの置き場所が悪かったようです。
credentialsファイルはユーザのホームディレクトリ配下に作成しなければいけませんでした。

mkdir ~/.aws
vi ~/.aws/credentials

適当な作業ディレクトリにawsディレクトリを作成して、その配下にcredentialsファイルを作成しておりましたが、ユーザのホームディレクトリ配下にcredentialsファイルを作成してコマンドの実行ユーザに紐付けしなければ、当然AWSへインスタンス作成はできないですよね。

これで無事AWSへインスタンス作成が完了です。

$ docker-machine create --driver amazonec2 --amazonec2-open-port 8000 --amazonec2-region ap-northeast-1 aws-sandbox
Running pre-create checks...
Creating machine...
(aws-sandbox) Launching instance...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env aws-sandbox
$ 

最後に

教材ではサラッと流されてしまうところ、一つ一つ重要視して進めていかないとうまくいかないですね。

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