Skip to content

Commit 0264377

Browse files
ubuntu docker instructions in; added jupyterlab desktop option
1 parent cf6ddad commit 0264377

File tree

2 files changed

+91
-35
lines changed

2 files changed

+91
-35
lines changed

img/setup/ubuntu-docker.png

206 KB
Loading

source/setup.Rmd

Lines changed: 91 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,86 @@ been verified to work on a computer that:
2222

2323
By the end of the chapter, readers will be able to do the following:
2424

25-
- Download the worksheets that accompany the chapters of this book from GitHub.
25+
- Download the worksheets that accompany this book.
2626
- Install the Docker virtualization engine.
27-
- Run JupyterLab with the R kernel inside a Docker container.
27+
- Edit and run the worksheets using JupyterLab running inside a Docker container.
28+
- Install Git, JupyterLab Desktop, and R packages.
29+
- Edit and run the worksheets using JupyterLab Desktop.
2830

2931
## Obtaining the worksheets for this book
3032

31-
The worksheets containing practice exercises for this book
32-
can be found at [https://worksheets.datasciencebook.ca](https://worksheets.datasciencebook.ca).
33+
The worksheets containing exercises for this book
34+
are online at [https://worksheets.datasciencebook.ca](https://worksheets.datasciencebook.ca).
3335
The worksheets can be launched directly from that page using the Binder links in the rightmost
3436
column of the table. This is the easiest way to access the worksheets, but note that you will not
3537
be able to save your work and return to it again later.
36-
3738
In order to save your progress, you will need to download the worksheets to your own computer and
3839
work on them locally. You can download the worksheets as a compressed zip file
3940
using [the link at the top of the page](https://github.com/UBC-DSCI/data-science-a-first-intro-worksheets/archive/refs/heads/main.zip).
4041
Once you unzip the downloaded file, you will have a folder containing all of the Jupyter notebook worksheets
4142
accompanying this book. See Chapter \@ref(getting-started-with-jupyter) for
4243
instructions on working with Jupyter notebooks.
4344

44-
## Running the worksheets with Docker (recommended)
45-
46-
Once you have downloaded the worksheets to your computer,
47-
you will next need to install and run the software required to work on Jupyter notebooks
48-
on your own computer. Doing this setup manually can be quite tricky, as it involves quite a
49-
few different software packages, not to mention getting the right versions of everything—the worksheets
50-
may not work unless all the versions are exactly right!
45+
## Working with Docker
5146

52-
To keep things simple, we instead recommend that you install [Docker](https://docker.com). Docker lets you
53-
run a pre-built *virtual machine* that comes with precisely the right versions of all software packages needed
54-
run the worksheets that come with this book.
47+
Once you have downloaded the worksheets, you will next need to install and run
48+
the software required to work on Jupyter notebooks on your own computer. Doing
49+
this setup manually can be quite tricky, as it involves quite a few different
50+
software packages, not to mention getting the right versions of
51+
everything—the worksheets and autograder tests may not work unless all the versions are
52+
exactly right! To keep things simple, we instead recommend that you install
53+
[Docker](https://docker.com). Docker lets you run your Jupyter notebooks inside
54+
a pre-built *virtual machine* that comes with precisely the right versions of
55+
all software packages needed run the worksheets that come with this book.
56+
\index{Docker}
5557

5658
### Ubuntu
5759

58-
https://docs.docker.com/engine/install/ubuntu/
60+
To install Docker on Ubuntu, open the terminal and enter the following five commands.
5961
```
6062
sudo apt update
6163
sudo apt install ca-certificates curl gnupg
6264
curl -fsSL https://get.docker.com -o get-docker.sh
6365
sudo sh get-docker.sh
6466
```
67+
Then in the terminal, navigate to the directory where you want to run JupyterLab, and run
68+
the following command.
69+
```
70+
docker run --rm -v $(pwd):/home/jovyan/work -p 8888:8888 ubcdsci/r-dsci-100:20230724142640d8f06f jupyter lab
71+
```
72+
The terminal will then print some text as the Docker container starts. Once the text stops scrolling, find the
73+
URL in your terminal that starts with `http://127.0.0.1:8888` (highlighted by the red box Figure \@ref(fig:ubuntu-docker-terminal)), and paste it into your browser to start JupyterLab.
74+
75+
```{r ubuntu-docker-terminal, echo = FALSE, fig.cap = "The terminal text after running the Docker container in Ubuntu. The red box indicates the URL that you should paste into your browser to open JupyterLab.", fig.retina = 2, out.width="100%"}
76+
image_read("img/setup/ubuntu-docker.png") |>
77+
image_crop("3632x2000")
78+
```
79+
80+
More information on installing and running Docker on Ubuntu, as well as troubleshooting tips, can be found
81+
[in the online Docker documetation](https://docs.docker.com/engine/install/ubuntu/).
82+
83+
### Windows
84+
85+
https://docs.docker.com/desktop/install/windows-install/
86+
use WSL 2 backend instructions
87+
run wsl --update in cmd.exe
88+
89+
Install Docker Desktop on Windows
90+
Install interactively
91+
Double-click Docker Desktop Installer.exe to run the installer.
92+
93+
If you haven’t already downloaded the installer (Docker Desktop Installer.exe), you can get it from Docker Hub. It typically downloads to your Downloads folder, or you can run it from the recent downloads bar at the bottom of your web browser.
94+
95+
When prompted, ensure the Use WSL 2 instead of Hyper-V option on the Configuration page is selected or not depending on your choice of backend.
96+
97+
If your system only supports one of the two options, you will not be able to select which backend to use.
98+
99+
Follow the instructions on the installation wizard to authorize the installer and proceed with the install.
100+
101+
When the installation is successful, click Close to complete the installation process.
102+
103+
If your admin account is different to your user account, you must add the user to the docker-users group. Run Computer Management as an administrator and navigate to Local Users and Groups > Groups > docker-users. Right-click to add the user to the group. Log out and log back in for the changes to take effect.
104+
65105

66106
### MacOS
67107

@@ -90,34 +130,49 @@ Use recommended settings (Requires password). This let’s Docker Desktop automa
90130
Use advanced settings. You can then set the location of the Docker CLI tools either in the system or user directory, enable the default Docker socket, and enable privileged port mapping. See Settings, for more information and how to set the location of the Docker CLI tools.
91131
Select Finish. If you have applied any of the above configurations that require a password in step 5, you are asked to enter your password to confirm.
92132

93-
### Windows
133+
## Working with JupyterLab Desktop
94134

95-
https://docs.docker.com/desktop/install/windows-install/
96-
use WSL 2 backend instructions
97-
run wsl --update in cmd.exe
135+
You can also run the worksheets accompanying this book on your computer
136+
using [JupyterLab Desktop](https://github.com/jupyterlab/jupyterlab-desktop).
137+
The advantage of JupyterLab Desktop over Docker is that it can be easier to install;
138+
JupyterLab Desktop runs entirely within your operating system (like most software!),
139+
while Docker doesn't and can sometimes run into some fairly technical issues that require expert
140+
troubleshooting. On the other hand, if you are able to successfully install Docker, it essentially
141+
*guarantees* that the worksheets will work exactly as intended. With JupyterLab Desktop, on the other
142+
hand, you may not end up with the right versions of all the R packages that are installed, and the
143+
worksheets may run into bugs.
98144

99-
Install Docker Desktop on Windows
100-
Install interactively
101-
Double-click Docker Desktop Installer.exe to run the installer.
145+
In this section, we will cover how to install Git (for version control, as discussed in Chapter \@ref(Getting-started-with-version-control)),
146+
JupyterLab Desktop, the JupyterLab Git extension, and all of the R packages needed to run the code in this book.
147+
\index{git!installation}\index{JupyterLab Desktop}
102148

103-
If you haven’t already downloaded the installer (Docker Desktop Installer.exe), you can get it from Docker Hub. It typically downloads to your Downloads folder, or you can run it from the recent downloads bar at the bottom of your web browser.
149+
### Ubuntu
104150

105-
When prompted, ensure the Use WSL 2 instead of Hyper-V option on the Configuration page is selected or not depending on your choice of backend.
151+
First, we will install Git. Open the terminal and type the following commands:
106152

107-
If your system only supports one of the two options, you will not be able to select which backend to use.
153+
```
154+
sudo apt update
155+
sudo apt install git
156+
```
108157

109-
Follow the instructions on the installation wizard to authorize the installer and proceed with the install.
158+
Next, visit the [Installation section of the JupyterLab Desktop homepage](https://github.com/jupyterlab/jupyterlab-desktop#installation).
159+
Download and run the installer for Ubuntu/Debian.
160+
To install the JupyterLab Git extension, run JupyterLab Desktop,
161+
open a notebook, and run the following code in a cell:
162+
```
163+
%pip install --upgrade jupyterlab-git
164+
```
165+
Finally, we will install the IRkernel and R packages
110166

111-
When the installation is successful, click Close to complete the installation process.
167+
TODO
112168

113-
If your admin account is different to your user account, you must add the user to the docker-users group. Run Computer Management as an administrator and navigate to Local Users and Groups > Groups > docker-users. Right-click to add the user to the group. Log out and log back in for the changes to take effect.
169+
### Windows
170+
171+
TODO
114172

115-
### Running the worksheets without Docker (advanced users)
173+
### MacOS
116174

117-
- Git
118-
- miniconda
119-
- JupyterLab
120-
- jupyterlab-git extension
175+
TODO
121176

122177

123178

@@ -172,7 +227,7 @@ so that they are compatible with the exercise worksheets that accompany the book
172227
> unixodbc
173228
> ```
174229
175-
Finishing up installation
230+
## Finishing up installation
176231
177232
It is good practice to restart all the programs you used when installing this
178233
software stack before you proceed to doing your data analysis.
@@ -182,6 +237,7 @@ This will ensure all the software and settings you put in place are
182237
correctly sourced.
183238
184239
240+
## OLD MATERIAL
185241
186242
### Git
187243

0 commit comments

Comments
 (0)