Workspaces
Workspaces are isolated development environments containing your project’s codebase, dependencies, packages, and configuration, providing a consistent and reproducible setup for development, testing, and deployment.
Workspaces serve as a core component of Daytona, allowing you to create, manage, and collaborate on projects in a controlled and secure environment.
Workspaces are hosted using a suitable Target infrastructure, such as a cloud-based and on-premises environments. They ensure that changes in one project do not inadvertently affect another, promoting a more stable and reliable workflow. This is particularly beneficial in collaborative settings, as it ensures that all team members are working with the same configuration, reducing the likelihood of environment-related issues.
Create a Workspace
Creating a Workspace in Daytona is a straightforward process that ensures you have a dedicated development environment for your projects.
Daytona provides two primary methods for creating a Workspace:
From a Git Repository
Creating a Workspace from a Git repository sets up a new development environment using a connected Git Provider or a custom Git repository URL.
- Run the following command to create a Workspace from a Git repository:
daytona create
- Select one of the three provided options:
-
Select from a List of Repositories
If you connected a Git Provider, you will be presented with a list of your repositories from which you can select to connect with your Workspace.
-
Enter a Custom Repository URL
Alternatively, select the option to enter a custom repository URL manually if the repository is not listed under your Git Provider account or is from an external source.
-
Create from Sample
If you do not have a Git repository ready, you can create a Workspace from a Sample project provided by Daytona. This option sets up a new development environment using quick-start templates.
Choose a Git Provider3 items===GitHubEnter a custom repository URLCreate from Sample
- Enter a name for your Workspace.
Workspace name>
- Select a Target to deploy your Workspace to. Selecting a Target will prompt you to input the Target configuration. The configurations vary based on the selected Target.
Upon Target selection and configuration, Daytona will clone the specified Git repository and set up a new Workspace based on its contents. You will see progress information in the terminal, indicating the process of creating a Workspace.
<Target> | ✓ Request submitted<Workspace> | Creating workspace <workspace> (<workspace_id>)<Workspace> | Pulling image...<Workspace> | Pulling from daytonaio/workspace-project<Workspace> | Digest: sha256:<sha256><Workspace> | Status: Image is up to date for daytonaio/workspace-project:latest<Workspace> | ✓ Image pulled successfully<Workspace> | UIDs and GIDs are the same (1000:1000).<Workspace> | Cloning into '/workdir/<workspace>'...<Workspace> | UIDs and GIDs are the same (1000:1000).<Workspace> | ✓ Workspace <workspace> created
From an Arbitrary Git URL
Creating a Workspace from an arbitrary Git URL sets up a new development environment by directly specifying the URL of the remote repository.
- Run the following command to create a Workspace from a remote Git repository:
daytona create <REPO_URL>
Example
daytona create https://github.com/daytonaio/daytona.git
- Select a Target to deploy your Workspace to. Selecting a Target will prompt you to input the Target configuration. The configurations vary based on the selected Target.
Upon Target selection and configuration, Daytona will clone the specified Git repository and set up a new Workspace based on its contents. You will see progress information in the terminal, indicating the process of creating a Workspace.
Once complete, the Workspace will be ready for use with the specified repository and configuration.
<Target> | ✓ Request submitted<Workspace> | Creating workspace <workspace> (<workspace_id>)<Workspace> | Pulling image...<Workspace> | Pulling from daytonaio/workspace-project<Workspace> | Digest: sha256:<sha256><Workspace> | Status: Image is up to date for daytonaio/workspace-project:latest<Workspace> | ✓ Image pulled successfully<Workspace> | UIDs and GIDs are the same (1000:1000).<Workspace> | Cloning into '/workdir/<workspace>'...<Workspace> | UIDs and GIDs are the same (1000:1000).<Workspace> | ✓ Workspace <workspace> created
List Workspaces
Daytona provides an option to keep track of your development environments by listing all previously created Workspaces. This helps you manage multiple development environments and ensure that you can easily access and maintain your Workspaces.
- Run the following command to list all your Workspaces:
daytona list
Upon running this command, Daytona will display a list of your Workspaces with their details. You will be able to see the Workspace name, the repository it is connected to, the target of the Workspace, and its status.
Workspace Repository Target Status Branch─────────────────────────────────────────────────────────────────MyWorkspace user/repository local STARTED (30 minutes) master
Open An Existing Workspace
Daytona provides an option to open an existing Workspace in your IDE. This enables you to quickly access and work on your Workspaces in your preferred development environment. With Daytona, you can effortlessly switch between different Workspaces and maintain an efficient workflow.
- Run the following command to open an existing Workspace:
daytona code
Upon running this command, Daytona will display a list of your Workspaces with their details. You will be able to see the Workspace name, the unique identifier of the Workspace, and the repository it is connected to.
Select a Workspace To Open1 item
MyProjectabcdefg12hi3 (local)github.com/username/MyProject.git
- Select the Workspace you want to open.
Delete Workspaces
Daytona provides an option to delete one or more Workspaces, helping you manage your development environments by removing those that are no longer needed.
- Run the following command to delete a Workspace:
daytona delete
Upon running this command, Daytona will display a list of your Workspaces with their details. You will be able to see the Workspace name, the unique identifier of the Workspace, and the repository it is connected to.
Select Workspaces To Delete1 item
MyWorkspaceabcdefg12hi3 (local)github.com/username/MyProject.git
-
Mark Workspaces for deletion by highlighting them and pressing
x
. -
Press
Enter
on the selected Workspace to delete it.
Delete: MyWorkspace
abcdefg12hi3 (local)github.com/username/MyProject.git
- Confirm the action.
Delete workspace(s): [MyWorkspace]?Are you sure you want to delete the workspace(s): [MyWorkspace]?
[Yes] [No]
Workspace MyWorkspace successfully deleted
Non-Interactively
Daytona provides an option to delete one or more existing Workspaces non-interactively, allowing for quick and automated cleanup of your development environments without manual selection.
- Run the following command, specifying the workspace names/UUIDs to delete:
daytona delete WORKSPACE_1 WORKSPACE_2
Upon running this command, Daytona will prompt you to confirm the deletion of the specified Workspace. You will be able to see the Workspace name that you are about to delete, and you will have the option to confirm or cancel the action.
Delete workspace(s): [MyWorkspace]?Are you sure you want to delete the workspace(s): [MyWorkspace]?
[Yes] [No]
- Confirm the action to delete the selected Workspace.
Workspace MyWorkspace successfully deleted
Forward Ports from a Workspace
Daytona supports flexible port forwarding, allowing you to access services running in a Workspace locally or via a shareable public URL. With port forwarding, you can work on your project in a Workspace and test your code externally.
Access a Port Locally
You can access services running in a Workspace on your local machine.
Prerequisite
- A running Workspace with at least one service accessible via TCP/UDP.
- Run the following command to forward a port from a running Workspace to your local machine:
daytona forward <PORT> <WORKSPACE>
Example: Allow local access to port 4321 of the example-dev-env
Workspace.
daytona forward 4321 example-dev-env
Upon running this command, Daytona will establish a port forwarding connection from the specified port in the Workspace to your local machine. The terminal will display a message indicating the local port where the forwarded connection is available:
Port available at http://localhost:4321
Access a Port via Public URL
You can access services running in a Workspace via a generated public URL. This allows you to share your work with others in real-time.
Prerequisite
- A running Workspace with at least one service accessible via TCP/UDP.
- Run the following command to generate a public URL for a port on a running Workspace:
daytona forward <PORT> <WORKSPACE> <PROJECT> --public
Example: Generate a URL to access port 4321 of the example-dev-env
Workspace.
daytona forward 4321 example-dev-env --public
Upon running this command, Daytona will first establish a local port forwarding connection and display a message indicating the local port where the forwarded connection is available.
Port available at http://localhost:4321
Then, Daytona will proceed to forward the port to a public URL. The terminal will display progress information and, upon completion, provide the generated public URL.
Forwarding port to a public URL...Port available at:https://4321-ABC1DeF2GhI3JkLmNoP4RSTuVZ5.try-eu.daytona.app
This URL can be shared with others to provide real-time access to the service running on the specified port in your Workspace.