Skip to main content

Create a Workspace

Create a Workspace

You can create a workspace either from the DevSpace CLI or through the DevSpace desktop application. A workspace can be created from a git repository, a local path or a docker container (e.g. golang:latest).

Upon successful creation, DevSpace will make the development container available through the ssh host WORKSPACE_NAME.devspace. Alternatively, DevSpace can automatically open the workspace in a locally installed IDE, such as VS Code or Intellij.

info

A workspace is defined through a devcontainer.json. If DevSpace can't find one, it will automatically try to guess the programming language of your project and provide a fitting template.

Via DevSpace Desktop Application

Navigate to the 'Workspaces' view and click on the 'Create' button in the title. Enter the git repository you want to work on or select a local folder.

Add Provider

If you haven't configured a provider yet, DevSpace will automatically open the provider modal for you. You can later add providers in the same way by navigating to 'Providers' > 'Add'

You can also configure one of the additional settings:

  • Provider: The provider to use for this workspace. Cannot be changed later.
  • Default IDE: The ide to open after successfully creating this workspace. Can be changed later.
  • Workspace Name: Override the automatically determined workspace name with this option. Cannot be changed later.
  • Prebuild Repository: A docker image repository such as ghcr.io/my-org/my-repo that contains prebuilds for this workspace. DevSpace will try to automatically find a fitting prebuild for this workspace in the given repository.

Then press Create Workspace to launch the workspace.

info

Under the hood, the Desktop Application will call the CLI command devspace up REPOSITORY

Note

You can set the location of your devspace home by passing the --devspace-home={home_path} flag, or by setting the env var DEVSPACE_HOME to your desired home directory.

This can be useful if you are having trouble with a workspace trying to mount to a windows location when it should be mounting to a path inside the WSL VM.

For example: setting devspace-home=/mnt/c/Users/MyUser/ will result in a workspace path of something like /mnt/c/Users/MyUser/.devspace/contexts/default/workspaces/...

Via DevSpace CLI

Make sure to install the DevSpace CLI locally and select a provider you would like to host the workspace on (such as local docker) via:

# Add a provider if you haven't already
devspace provider add docker

Git Repository

Run the following command in a terminal to start a new workspace:

# Create from git repository
devspace up github.com/microsoft/vscode-remote-try-node

You can check out specific states of the repository by appending a commit hash, branch or Pull Request slug to the repository url:

Branch: devspace up github.com/microsoft/vscode-remote-try-node@main
Commit: devspace up github.com/microsoft/vscode-remote-try-node@sha256:15ba80171af11374143288fd3d54898860107323
PR: devspace up github.com/microsoft/vscode-remote-try-node@pull/108/head # Only works for GitHub!
Private Git Repositories

DevSpace will forward git credentials to a remote machine so that you can also pull private repositories.

Multiple workspaces from the same repository

Use the --id flag to override the name of the workspace. This allows you to create multiple workspaces from the same repository.

Local Path

Run the following command in a terminal to create a new workspace:

# Create from a local path
devspace up ./path/to/my-folder

DevSpace will sync the folder into the remote machine and create a development environment from the devcontainer.json.

Docker Image

Run the following command in a terminal to create a new workspace from a docker image:

# Create from a docker image
devspace up ghcr.io/my-org/my-repo:latest

DevSpace will create the following .devcontainer.json:

{
"image": "ghcr.io/my-org/my-repo:latest"
}

Existing local container

If you have a local container running, you can create a workspace from it by running:

devspace up my-workspace --source container:$CONTAINER_ID 

This only works with the docker provider.

info

Using --recreate on a workspace based on an already existing container will be rejected.

Recreating a workspace

If you are working on the devcontainer.json or have pulled changes that affect the development environment, you can recreate a workspace. Recreating a workspace means to apply changes in the devcontainer.json or related Dockerfile to the development environment. If a prebuild repository is supplied, DevSpace will try to find the updated development environment image inside the prebuild repository and if not found will fall back to building it.

When recreating a workspace, changes only to the project path or mounted volumes will be preserved. All other changes made in the container will be lost.

Via DevSpace Desktop Application

Navigate to the 'Workspaces' view and press on the 'More Options' button on the workspace you want to recreate. Then press 'Rebuild' and confirm to rebuild the workspace.

Via DevSpace CLI

Run the following command to rebuild an existing workspace:

devspace up my-workspace --recreate

Resetting a workspace

Some scenarios require pulling in the latest changes from a git repository or re-uploading your local folder. If instead of recreating the devcontainer you need to completely restart your workspace from a clean slate, use Reset over Recreate.

** When recreating a workspace, no changes will be preserved! **

Via DevSpace Desktop Application

Navigate to the 'Workspaces' view and press on the 'More Options' button on the workspace you want to reset. Then press 'Reset' and confirm.

Via DevSpace CLI

Run the following command to reset an existing workspace:

devspace up my-workspace --reset