*** If you have not created a user in AWS IAM **
1.Click on IAM for services
2.Select a user from the menu on the left
3.Click Add User
4.Enter any user name
5.The type of access is programmatic access
6.Click next step
7.Set permissions to "Attach existing policy directly"
8.Check "Administrator Access".
9.Press the next step.
10.Press the next step.
11.If there are no problems, click "Create User".
When the user creation is completed, the access key and secret access key will be displayed, so make a note of them. You can check the secret access key by clicking "View". These are the keys to connecting to AWS **, so don't lose them.
** If you have already created a user **
1.Click on IAM for services
2.Select a user from the menu on the left
3.Click on any username
4.Click Add Access Privilege on the Access Privileges tab
5.Set permissions to "Attach existing policy directly"
6.Check "Administrator Access".
Make sure that ** "Administrator Access" ** is added to the access authority.
-#Move to home directory
% cd
-#In your home directory.ls because it becomes a hidden file when creating "aws"-You can check with a.
% mkdir ~/.aws
-#Credential settings
% vim ~/.aws/credentials
-#Enter the two keys you noted earlier
[default]
aws_access_key_id = xxxxxxx
aws_secret_access_key = xxxxxxx
-#Example
% docker-machine create —-driver amazonec2 —-amazonec2-open-port 8000 —-amazonec2-region ap-northeast-1 aws-sandbox
** --driver ** is the specification of amazonec2. ** --amazonec2-open-port 8000 ** The port 8000 of the instance started is open to the outside. ** --amazonec2-region ap-northeast-1 ** is the region specification. ap-northeast-1 is the designation of the Tokyo region. ** aws-sandbox ** is specified as the host with the name "aws-sandbox".
Check the instance of EC2 and you can see that the instance is created by "aws-sandbox".
-#Setting environment variables to connect to docker host
% eval $(docker-machine env aws-sandbox)
-#Helllo displaying a test page-world-Launch a container called webserver using nginx
% docker run -d -p 8000:80 —-name webserver kinematic/hello-world-nginx
-#Check the ip of docker host
% docker-machine ip aws-sandbox
52.199.66.11
Confirm that the web page is displayed at 52.199.66.11: 8000.
-#Stop container
% docker-machine stop aws-sandbox
Stopping "aws-sandbox2"...
Machine "aws-sandbox2" was stopped.
Make sure that the EC2 instance state is ** "stopped" **.
-#docker host delete command
% docker-machine rm aws-sandbox
About to remove aws-sandbox
WARNING: This action will delete both local reference and remote instance.
-#Enter y
Are you sure? (y/n): y
Successfully removed aws-sandbox
Make sure that the EC2 instance state is "terminated".
Recommended Posts