I'm trying to connect VS Code Remote Development to a JupyterLab server running on Google Cloud with AI Platform (a Notebook instance).
How do I add a ssh host that connects not to the vm, but the docker container running the JupyterLab server?
I want to be able to edit source in that container from my local laptop's VS Code
I'm aware of gcloud compute config-ssh
, which edits my ~/.ssh/config
and adds a Host
entry, which VS Code can use to connect to the VM. But I need to go a level further, into the file system of the docker container running there.
EDIT: The premise of my question is wrong, I've learned. jupyterlab doesn't run in a container; it runs on the VM normally. So, ssh
'ing in to the VM gives me access to the same filesystem as what's available to jupyter. The only catch is specifying the jupyter
user to ssh
.
Google has docs on Using ssh to access JupyterLab. If you're running on a VM and know the instance name, you can establish an SSH tunnel into the VM. From the docs:
Follow these steps to set up SSH port forwarding and then access your JupyterLab session through a local browser:
Type the following command in either Cloud Shell or a local environment where the Cloud SDK is installed.
gcloud compute ssh --project PROJECT_ID \ --zone ZONE \ INSTANCE_NAME -- -L 8080:localhost:8080
Replace the following:
PROJECT_ID
: Your project IDZONE
: The Google Cloud zone where your instance is locatedINSTANCE_NAME
: The name of your instanceIf you ran the command on your local machine, visit https://localhost:8080 to access JupyterLab.
If using Cloud Shell, access JupyterLab through the Web Preview on port 8080. The Web Preview button Web Preview Button can be found on the top right of the Cloud Shell taskbar.
If you're running a Notebooks instance, go to the Notebooks page and click on the instance name. You should see a way of connecting via cloud shell or SSH. If you're running a DataProc JupyterHub cluster you'll need to look for your pod in your kubernetes workloads. From the pod page, you should have a menu icon which allows you SSH access through KUBECTL.