How to run Cloud Datalab on your laptop

Cloud Datalab is the hosted way to run Jupyter notebooks on Google Cloud. But if you run a lot of managed services (Cloud ML Engine, Dataflow, BigQuery, etc.), you don’t really need a powerful VM — your laptop is enough. At the same time, it can be helpful to have a git repository on your local laptop, develop Python files in PyCharm, and still use Datalab for its GCP integration.

Can you run Datalab on your laptop?

Yes. This is what I do (note: this is completely unofficial and unsupported):

  1. Install Docker on your laptop.
  2. Install the gcloud SDK on your laptop
  3. In a terminal, run ```gcloud auth login``` to login to your project
  4. In the same terminal, save and run run this script (change the CONTENT) variable first!
#!/bin/bash
IMAGE=gcr.io/cloud-datalab/datalab:latest
CONTENT=${HOME}/code/training-data-analyst # your git repo
PROJECT_ID=$(gcloud config get-value project)
if [ "$OSTYPE" == "linux"* ]; then
PORTMAP="127.0.0.1:8081:8080"
else
PORTMAP="8081:8080"
fi

docker pull $IMAGE
docker run -it \
-p $PORTMAP \
-v "$CONTENT:/content" \
-e "PROJECT_ID=$PROJECT_ID" \
$IMAGE

Now, you can simply browse to http://localhost:8080/ and from there open any notebook in your local repo, and work on it using Datalab.

--

--

A collection of technical articles and blogs published or curated by Google Cloud Developer Advocates. The views expressed are those of the authors and don't necessarily reflect those of Google.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lak Lakshmanan

Operating Executive at a technology investment firm; articles are personal observations and not investment advice.