Q: How to open jupyter notebook from a container in aws after building the Dockerfile, I've created an image of my application.
I'm doing the following steps in my AWS EC2 Instance CLI to run the image w/ a container:

*

*docker run -it -p 8879:8879 my-image

*jupyter notebook --ip 0.0.0.0 --no-browser
Now I'm trying to access this jupyter notebook from my computer, obviously localhost doesn't work because it's executed from my aws ec2 instance.
What I tried is ip address of my ec2 instance with 8879, I also tried finding the docker
s ip address (in my ec2 instance cli) and attaching to it 8879..
Any ideas how to get it to work?

A: You'll need to have the port 8879 open in your instance security group settings or all this won't work.

On your local machine, in a terminal use port forwarding to make an SSH tunnel.
See:

*

*https://coderwall.com/p/ohk6cg/remote-access-to-ipython-notebooks-via-ssh


*Running Jupyter on a remote docker container via SSH


*This Jupyter Discourse forum discussion has an example of this &  may contain more tips along these lines. (Plus, here.)
(The -L option is the most critical part and the only part I generally use.)
For me, the port forwarding command establishing the tunnel using your ports, I suspect would look something like this:
ssh -i <your_key_file_prefix>.pem -L 8888:localhost:8879 ubuntu@<IP_ADDRESS_OF_YOUR_EC2_INSTANCE>

With the stuff between the carets replaced appropriately.
Once you have a terminal window with the tunnel established, leave it open. You'll also have the ssh connection open running the remote jupyter notebook server.
Now you can return to trying to connect from inside your browser window.
Depending on how you set it up, it may want the token, and so collect that from the message you got when you start the Jupyter notebook server running on the EC2 instance.
So you will have something like this that you work out and paste in your browser window on your local machine after you establish the SSH tunnel:
http://localhost:8888/?token=b9714ff53b7fb7c9f750f8a8a2bdeaae6d3ce3643b209d81

Try it without the token first if you think you set it up to not need it.
