How to run Cloud Datalab on your laptop

Lak Lakshmanan
Oct 5, 2018 · 1 min read

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?

This is how you can run Datalab even when you are not connected to the Cloud

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.

Google Cloud - Community

Google Cloud community articles and blogs

Lak Lakshmanan

Written by

Data Analytics & AI @ Google Cloud

Google Cloud - Community

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.

Lak Lakshmanan

Written by

Data Analytics & AI @ Google Cloud

Google Cloud - Community

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.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

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