Skip to content

Instantly share code, notes, and snippets.

@echuber2
Last active December 9, 2022 23:30
Show Gist options
  • Save echuber2/2dd51ab799411cbd4894f8a85a3db52c to your computer and use it in GitHub Desktop.
Save echuber2/2dd51ab799411cbd4894f8a85a3db52c to your computer and use it in GitHub Desktop.
Local tester for Rocker RStudio image on M1 Macs
#!/bin/bash
# Local tester for the PrairieLearn Workspaces version of Rocker. We'd like to
# find out if this truly works on M1 Macs (and why). The macOS version of
# Docker Desktop should handle permissions appropriately here, but this script
# may not work on Windows and Linux. If you are not using macOS, just use
# normal Rocker instead of this script.
# 20220111 Eric Huber
# USAGE INSTRUCTIONS
# 1. Edit the LOCAL_MOUNT variable below to whatever working directory you'd
# like to mount into the container. The session uses /home/rstudio/workspace
# as the working directory, so your mount will be at: /home/rstudio/workspace/rocker-mounted
# 2. Run this script with:
# bash ./pl-rocker-local-test.sh
# 3. You'll see some warnings and errors about s6 that you can ignore,
# and eventually "Starting nginx". Then go here in your browser:
# http://localhost:3939/rstudio
# ---
# Pull the PrairieLearn version of the Rocker image
# (After the first download, comment out this line for faster restarts.)
sudo docker pull prairielearn/workspace-rstudio
# Prepare a local directory to be mounted inside the container read-write
LOCAL_MOUNT="$HOME/rocker-mounted"
mkdir -p "$LOCAL_MOUNT"
sudo docker run -it --rm -v "$LOCAL_MOUNT:/home/rstudio/workspace/rocker-mounted" -p 127.0.0.1:3939:3939 -u 0 prairielearn/workspace-rstudio
@njudd
Copy link

njudd commented Dec 9, 2022

Works macOS Monterey 12.5 on an M1 14inch pro; Docker version 20.10.17, build 100c70180f

Thanks a mil!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment