Skip to content

Use Visual Studio Code with a Run:ai Job

Once you launch a workload using Run:ai, you will want to connect to it. You can do so via command-line or via other tools such as a Jupyter Notebook

This document is about accessing the remote container created by Run:ai, from Visual Studio Code.

Submit a Workload

You will need your image to run an SSH server (e.g OpenSSH). For the purposes of this document, we have created an image named The image runs both python and ssh. Details on how to create the image are here. The image is configured to use the root user and password for SSH.

Run the following command to create the interactive workload:

runai submit build-remote -i --interactive


Job build-remote submitted successfully.
You can check the status of the job by running:
    runai describe job build-remote -p ziggy

Run the following command to connect to the container as if it were running locally:

runai port-forward build-remote --port 2222:22

The terminal will show the connection:

open access point(s) to service from localhost:2222
Forwarding from -> 22
Forwarding from [::1]:2222 -> 22
Handling connection for 2222

  • The Job starts an sshd server on port 22.
  • The connection is redirected to the local machine ( on port 2222


It is possible to connect to the container using a remote IP address. However, this would be less convinient as you will need to maintain port numbers manually and change them when remote accessing using the development tool. As an example, run:

runai submit build-remote -i -g 1 --interactive --service-type=nodeport --port 30022:22

* The Job starts an sshd server on port 22.
* The Job redirects the external port 30022 to port 22 and uses a [Node Port]({target=_blank} service type.
* Run: `runai list jobs`

* Next to the Job, under the "Service URL" column you will find the IP address and port. The port is 30222

Visual Studio Code

  • Under Visual Studio code install the Remote SSH extension.
  • Create an ssh entry to the service by editing .ssh/config file or use the command Remote-SSH: Connect to Host... from the Command Palette. Enter the IP address and port from above (e.g. ssh [email protected] -p 30022 or ssh [email protected] -p 2222). User and password are root
  • Using VS Code, install the Python extension on the remote machine
  • Write your first python code and run it remotely.