---
title: "Day-0: Setting up RStudio using Docker"
canonical: "https://help.biobam.com/space/BTP/3316711439/Day-0%3A%20Setting%20up%20RStudio%20using%20Docker"
format: markdown
---
In this tutorial, we'll walk you through how to set up RStudio, an open-source Integrated Development Environment (IDE) for R, using docker. Docker will allow us to run RStudio in a self-contained and reproducible environment.

## Prerequisites

Before we begin, ensure that you have docker installed on your system. If you don't have docker installed, you can follow these tutorials based on your operating system:

- [Docker for Windows](https://biobam.atlassian.net/wiki/spaces/BTP/pages/3316547587)
- [Docker for Mac](https://biobam.atlassian.net/wiki/spaces/BTP/pages/3316482049)
- [Docker for Linux (Ubuntu)](https://biobam.atlassian.net/wiki/spaces/BTP/pages/3316908033)

## Downloading the Docker Image

1. Open your terminal (MAC, Linux) or PowerShell (Windows).
2. Enter the following command to download the `spriyansh29/sdac_2023` Docker image from Docker Hub:

```
docker pull spriyansh29/sdac_2023:latest
```

![image](media://a4042b86-7c32-4010-9ec8-0851d8d5b0c7)

## Running the Docker Container (To verify the pull)

To start a container from the downloaded image, follow these steps:

1. Input the following command in your terminal (MAC, Linux) only.

```shell
docker run -p 8787:8787 --rm -e USERID=$(id -u) -e USER=esr -e PASSWORD=biobam spriyansh29/sdac_2023:latest
```

2. For Windows type the following in PowerShell,

```
docker run -p 8787:8787 --rm -e USER=esr -e PASSWORD=biobam spriyansh29/sdac_2023:latest
```

Here's what this command does:

- `-p 8787:8787` maps port 8787 of your machine to port 8787 inside the container.
- `-e USER=esr -e PASSWORD=biobam` sets the environment variables for the username and password of the RStudio Server.
- `spriyansh29/sdac_2023:latest` indicates the Docker image and its tag.

Once you have it up and running on your terminal, you should see some logs as follows,

![image](media://281c2a6b-6fed-40a3-9324-eaa36216b7d3)


## Accessing RStudio Server

1. Open your preferred web browser.
2. In the address bar, type:
4. You'll be prompted for a username and password. Input:

- **Username:** esr
- **Password:** biobam

![image](media://58953b5b-f4dd-4bfc-9fa8-9b86574f5608)


## Testing

To confirm that RStudio operates as expected, follow these steps:

1. Inside RStudio's interface, navigate to `File > New File > R Script`
2. In the newly created script, type:

```
print("Hello, World!")
```

3. Click on "Run" or press `Ctrl+Enter` to execute the command.
4. If "Hello, World!" appears in the console, your setup is successful!

## Closing the running container

- Return to the terminal where the Docker container is running.
- Press `Ctrl+C` to stop the container or type `docker rm -f $(docker ps -aq)` in a terminal (MAC, Linux) or PowerShell (Windows).

> 📝 **Note:** The command `docker rm -f $(docker ps -aq)` stops all running Docker containers. It's not recommended for shared systems.

Congratulations! You now have RStudio running in a Docker container. Let's now download the data.