Local Development - Developing with a local copy of PrairieLearn

Use these instructions to launch PrairieLearn on your local machine using Docker.

Prerequisites

These are one-time setup steps.

  1. Install Docker Desktop
  2. Sign in to Docker
    docker login
    
  3. Clone your course repo

    Your course repo is, for example:

    git clone git@github.com:PrairieLearn/pl-ucsb-cmpsc110.git
    cd pl-ucsb-cmpsc110
    

Run PrairieLearn with script (if present)

Many of the repos used with PrairieLearn at UCSB have a script inside called ucsb-pl.sh.

If your repo doesn’t, skip ahead to the next heading (“Run PrairieLearn (no external grader)”)

Once you’ve installed Docker (as described above) to start up PrairieLearn in local mode in these repos, simply navigate to the repo, and run the script.

For example:

git clone git@github.com:PrairieLearn/pl-ucsb-cmpsc5a.git
cd pl-ucsb-cmpsc5a
./ucsb-pl.sh

Wait for the message that the server is running on localhost:3000, then navigate to http://localhost:3000.

Click “Load From Disk”, and then access your course.

Run PrairieLearn (no external grader)

First, cd into the directory where you cloned the PrairieLearn course repo, and update the main branch.

cd pl-ucsb-cmpsc110
git pull origin main

Then start docker:

docker run -it --rm -p 3000:3000 --pull=always -v `pwd`:/course prairielearn/prairielearn:us-prod-live

Access PrairieLearn in Browser

Once you see this message:

info: PrairieLearn server ready, press Control-C to quit
info: Go to http://localhost:3000
  • Open your browser and go to http://localhost:3000
  • Click the Load from Disk button upper right:

    image

  • After the course loads, click the Back to Previous Page button upper left:

    image

  • Then you should see your course, and be able to try questions.

Common Error: Docker Daemon Not Running

If you see this error:

Cannot connect to the Docker daemon at unix:///Users/.../.docker/run/docker.sock

Solution:

  • Open Docker Desktop from Applications or Launchpad
  • Wait for it to fully start (🐳 whale icon turns green)
  • Then retry the docker run command

Table of contents