# How to Connect Jupyter from Local Client to Server Docker Container
---
We will use 4 ports in this introduction, *port1*, *port2*, *port3*, *port4*.
## 1. Connect to server via ssh
ssh to server via *port1*, *port1* is the forward port from router of server.
**Example:** `ssh usr@192.168.1.1 -p3000`
## 2. Open port on docker container
When you create a new container in server, don't forget add the parameter `-p port2:port3`,
*port2* is the port of container, and *port3* is the port of server.
**Example:** `docker run -it --gpus all --name edinhon -p 8080:8080 nvidia/cuda:11.0-base`
## 3. Run Jupyter on server container
Run jupyter on container, add the parameter `--ip`, `--no-browser`, `--port port2`, `--allow-root`.
There is a token of jupyter in the output message.
**Example:** `jupyter notebook --ip 0.0.0.0 --port=8080 --no-browser --allow-root`
## 4. Allow port3 in the firewall of the server
If the server has firewall, open the *port3* in the firewall.
## 5. Connect to server via ssh
Connect to server from local *port4* to server *port3*. *port4* is the port of local client.
`ssh -N -L port4:localhost:port3 usr@ip -pport1`
**Example:** `ssh -N -L 8080:localhost:8080 usr@192.168.1.1 -p3000`
## 6. Open Jupyter in local by browser
Enter `localhost:port4` in browser and input token of step3. Congratulation~
###### tags: `docker` `jupyter`