Windows 10 Pro/Education
This guide shows you how to install Docker and run R/RStudio virtually using an environment we have created called darribas/gdsr:1.0
. This approach is preferred for anyone using ‘Windows 10 Pro/Education’ because it avoids potential compatibility issues between the latest versions of R/RStudio and other software on your computer.
Please therefore follow these steps even if R/RStudio is already installed on your computer.
Installing Docker
Requirements
To be able to complete this guide, your machine will need to meet the following requirements:
- A stable internet connection
- ~10GB of space on your hard drive
- Windows 10 64-bit: Pro, Enterprise, or Education (Build 16299 or later). You can see the full requirements on the official Docker for Windows page.
IMPORTANT:
If you are not sure what version of Windows you are running, check out this guide.
If you know you don’t have Windows 10 Pro, for example you are running Windows 10 Home, please use this install/run guide.
Docker install steps
Once you have everything required ready to go, the first step is to install the Docker Desktop App for Windows. Here are the steps you can follow:
- Head over to Docker Hub to download a copy of Docker for Windows:
https://hub.docker.com/editions/community/docker-ce-desktop-windows/
- Download a copy of the Docker Desktop (highlighted in red on the image above). Click “Save File”. Note the file is approximately 490Mb so, depending on your internet connection, it might take a while to download.
- Double click on the file you downloaded (a cute white whale on a blue background) and the “installation wizard” will appear.
- Follow the instructions on the installation wizard to authorize the installer and proceed with the install.
You can check the process has completed successfully by following these steps:
- Open PowerShell from the “Start Menu”
- Check Docker is available by printing out the version you have installed:
docker --version
Note: Don’t worry if you have you installed a slightly different version of Docker - that’s OK. What you want to make sure is that it successfully prints out a version instead of a warning/error message (usually in red).
Installing the container
Once you have Docker installed and running on your machine, installing everything you need to run RStudio and associated packages boils down to the following two steps:
- Open PowerShell following the same steps as above (you can use the same window as before or a fresh new one).
- Run (type and hit “Enter”) the following command:
docker pull darribas/gdsr:1.0
You will know this has completed when each line says ‘Pull complete’.
IMPORTANT:
Make sure you are connected to the internet and it is a stable connection. This step involves the download of large amounts of data (ca. 10GB) so it might take a while. However, it only needs to be run once.
Check success
If everything has gone according to plan, you should see darribas/gdsr
show up on your terminal when you type docker image ls
:
Running RStudio Server
The following sections cover how to start up the software you have just installed, use it, and shut it down when you are done.
Running the container
- In a new PowerShell window, type the following command to run the container and hit enter:
docker run -d -e PASSWORD=test123 -p 8787:8787 -v ${PWD}:/home/rstudio/work darribas/gdsr:1.0
You have now started an RStudio session.
IMPORTANT:
Please do NOT close the PowerShell window until you are finished in this RStudio session
- To access this session go to your chosen web browser (e.g. Firefox/Chrome) and type:
localhost:8787
into the search bar. - The page that loads will prompt you for a username and password as shown. Type the following:
username: rstudio
password: test123
Now you are in RStudio Server, you can start coding or opening a new file. Please refer to Rowe and Arribas-Bel (2021) for an introduction to the RStudio interface, R Script and R Notebook.
Using RStudio Server
A R notebook is where you will run your code and can add text. The top header is called YAML metadata and each shaded box is called a kernel (or code chunk) contained within delimiters {r} and
.
Type 1 + 1 into a code chunk. To run the code click the play icon as highlighted in red below.
IMPORTANT:
Make sure you save files you want to keep ONLY within the work
folder, as this will ensure they are saved on your machine.
Everything saved outside the work
folder will be destroyed as soon as you shut down the session.
You can access other files on your machine through the work folder in the Files Browser. From here you can navigate to your Documents and designated folder for this module.
Here I am navigating to the san folder that we have created for this module in my Downloads. You can replace this with the pathway to the folder you create for this module.
You can save your notebook here using File > Save As.
And you can create new folders to organise your work.
Ending your session
Once you have finished in your RStudio session and have saved all your work, you can end the session by closing your browser.
Then, type docker container stop and copy the CONTAINER ID from the output above as shown here:
You can now safely shut the terminal window.
Next time you go to run a R Notebook you will NOT need to repeat the whole process as you have already installed Docker and the GDSR environment. Instead you can start from Running the container and carry on from there.