> ## Documentation Index
> Fetch the complete documentation index at: https://namespace.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# nsc exec-scoped

Run a command with environment variables set based on selected services.

`exec-scoped` runs the specified command (e.g. a script) against an instance, after
first setting the environment variables that the selected services expect — for
example `DOCKER_HOST` for `docker`, or `KUBECONFIG` for `kubernetes`. This makes it
possible to point an existing script or tool at a Namespace instance's Docker or
Kubernetes endpoint without manually exporting those variables yourself.

Which services get wired up is controlled with `--service`. The corresponding
environment variables are only set for the lifetime of the child process that
`exec-scoped` starts; they aren't exported into your interactive shell.

## Usage

```bash theme={null}
nsc exec-scoped --service=docker|kubernetes <clusterid> <cmd...>
```

### Example

```bash theme={null}
nsc exec-scoped --service=docker,kubernetes 85a32emcg99ii ./deploy.sh
```

## Options

<h3 id="--service-strings">
  \--service strings
</h3>

Which services to inject, any of: `docker`, `kubernetes`. Pass a comma-separated
list to set up environment variables for more than one service at once — for
example `--service=docker,kubernetes` sets both `DOCKER_HOST` and `KUBECONFIG`
before running `<cmd...>`.

## Related Topics

* [nsc kubeconfig write](/docs/reference/cli/kubeconfig-write) - Generate a kubeconfig to connect to an instance
* [nsc docker remote](/docs/reference/cli/docker-remote) - Run docker on the target instance
