I was recently setting up an EC2 instance on AWS and thought it would be useful to document the very common terminal commands that are needed to set up your instance to work with docker containers and docker-compose. This article will show you how to ssh into an EC2 instance set up on AWS and install docker and docker-compose.
Once you have launched your instance on the AWS console you will then need to create a key/pair. Select the key pair type you want and the Private key format. For this application I chose:
Once you have created that, then download the key onto your machine.
Restrict access to that key:
(Replace the path to the key to whereever you have saved the key on yourmachine.)
Then you can ssh into the server with that key:
Type yes when prompted to finalise the ssh process into the server. Next you want to run an update to make sure everything on the server is up to date:
Then you can install docker:
Once this installation process has finished you can log out of the machine(ctrl + d) and log back in to complete the installation. To test it is working as expected, ssh back into the machine and type:
It should print out this:
Next install docker-compose
And again once this installation process has finished you can log out of themachine (ctrl + d) and log back in to complete the installation.
So thats it! Nothing super complicated there but it's the sort of thing you do regularly enough that you need to know this process but not regularly enough that you can remember all the steps easily. At least I can't. Hope this is useful to some of you and I look forward to continuing to learn about AWS.