How to Install Jupyter Notebook on a Cloud Server?

This page is also available in: 中文

This is an extension of "What is a Jupyter Programming Notebook?" and will guide you on how to install your own Jupyter notebook on a cloud server.

You will need to prepare a cloud server and a domain name (A record pointing to the public IPv4 address of the cloud server). If you don't have them yet, you can refer to the following articles:

For those who are just starting to learn Python data analysis, a low-spec cloud server for US $5/month is sufficient to run Jupyter notebook programs. You can purchase one from the following platforms:

Installation Process

The installation process for Docker and Caddy has been covered in the article "How to Deploy Open Source Automation Workflow Software n8n using Docker + Caddy?", so it will not be repeated here.

Create Jupyter Container

Execute the following command in the terminal:

sudo docker run - d--name jupyter \
  -v jupyter_data: /home/jovyan \
  -p 172.17.0.1:8888:8888 \
  --restart unless - stopped \
  jupyter / minimal - notebook \
  start - notebook.sh--NotebookApp.allow_remote_access = True \
  --ServerApp.allow_origin='*'

Edit Caddyfile

Here we use the domain name torchtree.com as an example, please replace it with your actual domain name.

torchtree.com {
  reverse_proxy 172.17.0.1:8888
}

After editing the Caddyfile, you need to restart Caddy:

sudo docker restart caddy

Frequently Asked Questions

If you find that Jupyter cannot be accessed, it may be because the server has a firewall enabled. You can execute the following command to check for Ubuntu Server systems.

# Check if the firewall is enabled
sudo ufw status

# If the firewall is enabled and only SSH/22 port is open,
# execute the following commands to open ports 80 and 443
sudo ufw allow http
sudo ufw allow https

# If you prefer, you can also disable the firewall
sudo ufw disable

Now, you can run your Jupyter notebook in the cloud, enjoying more powerful computing resources, convenient collaboration methods, and a flexible working environment.

This article was published on 2024-01-24 and last updated on 2024-01-24.

This article is copyrighted by torchtree.com and unauthorized reproduction is prohibited.