---
title: Your first sandbox
description: Create a sandbox, run a command, and remove it with the carton CLI.
sidebar:
  label: CLI quickstart
---

Start here after [installation](/docs/installation) and
[connection setup](/docs/configuration).

Replace `IMAGE` in the command below with an image reference prepared for
your configured provider. Choose another sandbox name if `hello` already
exists.

## Create a sandbox

```sh
carton create IMAGE --name hello
```

Carton uses the default route from your configuration to choose a provider.
The CLI waits up to 60 seconds for readiness. Confirm the sandbox is ready
before running your command.

## Run a command

```sh
carton exec hello -- echo "Hello from carton"
```

You should see `Hello from carton` in your terminal. The CLI forwards the
command's output and exit status.

Arguments after `--` go to the sandbox command. For shell syntax such as
pipes or redirection, invoke a shell:

```sh
carton exec hello -- sh -c 'echo hello > /tmp/hello.txt'
```

## Copy a file

```sh
carton cp hello:/tmp/hello.txt ./hello-from-carton.txt
```

Choose another destination if that local file already exists. You can copy in
the other direction by putting the local path first.

## Inspect and clean up

```sh
carton ls
carton destroy hello
```

Destroy the sandbox when you finish to avoid leaving provider resources
running. Your downloaded file stays on your machine.

For the programmatic version of this lifecycle, see the
[SDK preview](/docs/sdk). For provider-specific setup, see
[Providers](/docs/providers).

<!-- Sources: crates/carton/src/client.rs (Create, Exec, Cp, Ls, Destroy), docs/server.md (readiness and execution). IMAGE is a user-supplied placeholder, not a published default image. -->
