Skip to content

Instantly share code, notes, and snippets.

@git-hamza
Last active March 21, 2022 13:25
Show Gist options
  • Save git-hamza/69289b2e9a7d4122e42df9b84edb0eff to your computer and use it in GitHub Desktop.
Save git-hamza/69289b2e9a7d4122e42df9b84edb0eff to your computer and use it in GitHub Desktop.
Accessing Jupyter notebook locally from docker hosted in remote server

SSH to the remote server:

Open cmd/terminal and connect the local port to the remote server port. ssh -L 127.0.0.1:3000:0.0.0.0:1234 USER@IP

Start the docker container inside the remote server:

For starting the docker, make sure to keep the port same as provided above. An example of starting a docker is given below. docker run -it -p 1234:8888 IMAGENAME /bin/bash

Run Jupyter Notebook:

Now that you have run the above command with /bin/bash, it will take you inside the docker container. Make sure to have jupyter notebook installed in there. Run the following command inside the docker container terminal. jupyter notebook --ip 0.0.0.0 --allow-root

Enjoy the notebook in your local browser:

After running the above command, something like http://127.0.0.1:8888/?token=2617735e9f289f5f318a8c0e will be outputed. Replace the 8888 in the address with the port you provided in the first step i.e. 3000 and paste the link http://127.0.0.1:3000 in your local browser. It will ask for a token; paste the token from the link there and enjoy using jupyter notebook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment