Opening Jupyter Notebooks through an EC2 AWS Instance(in just 15 “simple” steps)
Id imagine most people are in the same boat as I was when wanting to use AWS with Jupyter Notebooks, where do I start??? Well first things first you need to of course create an AWS Free Tier account which is simple enough right? Just follow this link to set up your free account. Make sure you follow any followup email instructions to ensure your account activates and is ready for use! Now lets get to creating an instance…..
1. From your AWS Console, type EC2
in the search bar. This will send you to the EC2 dashboard.
At this point you should be on your main EC2 dashboard, on the scroll bar on the left hand side of the screen locate Network and Security and follow the instructions below.
2. Under the “Network and Security” navigation group in your EC2 dashboard, select “Key Pairs”
3. Click on “Import Key Pair” button at the top of your screen.
4. (If Necessary) Create a Key Pair from the command line.
At this point you may not have a public key set up, thats ok! Here are the commands you will need to run to get on from your command line.
If when you run this it doesn’t work you will have to run the command below to create this file, this only needs to be done 1x!!!
Once you have run the above commands you should have a public key to copy into your Import Key box from Step 3. The default path for your public key should be your home directory ~/.ssh/id_rsa.pub
and should be filled in by default (just hit enter when prompted for a path). It should look something like this, make sure to copy everything from ssh to .local from your terminal.
5. From the EC2 dashboard click “Launch Instance”.
6. Choose the Ubuntu Image seen below, it should be down the list a few rows.
7. Choose the instance size(note: you will only be able to choose 1 option for free tier) click “Review and Launch”.
8. Click “Launch”.
Select the key pair named the same as the key you previously imported from step 4. If you created a key previously created Home Computer, then you should use that one.
9. Click the link similar to the one below to take you to your instance page:
10. Eventually you’ll see a green dot next to your instance, letting you know it’s ready. Take note of of the “Public DNS” line. You’ll use that url to SSH into your instance.
11. Lets SSH into our new instance. Using the code below add in the public DNS from your instance as seen above to enter your Ubuntu EC2 instance. Enter this into your command line.
12. At this point you should be on a screen that looks something like this:
You will also see a line that says Ubuntu@[Your_IP] this is your command line for your new virtual instance.
13. Docker Install on AWS EC2 instance:
Login to your EC2 instance and pipe the remote script to a shell using this curl
command:
Then after you’ve installed Docker on your Ubuntu Linux system, the install script will instruct you to add the ubuntu
user to the docker
group:
After you add your ubuntu
user to group docker
, simply exit and re-login.
14. Log back into your EC2 instance following the steps above, at this point you will need to run this command to log into Jupyter Notebooks Docker Image.
This will download the image/container that is preconfigured with pandas, scipy, scikit-learn, jupyter notebook, and the most common scientific Python libraries configured for data science.
15. At this point you should be able to log into Jupyter Notebooks and start enjoying the fun!!! The screen shot below shows how to access your jupyter notebook via your browser, it will prompt you for a token and simply use the token seen in the picture below(Yours will be different) and enjoy!!!
I hope this works for you the same way it worked for me, this is a brave new world of computing and I will see you soon when I learn more about this amazing platform!
Connect with me on Linkedin! https://www.linkedin.com/in/jonathancbeatty/