nsc docker attach-context

Attach your local Docker to an ephemeral environment.

docker attach-context configures a Docker context that uses an ephemeral environment.


nsc docker attach-context {--new | --to <cluster-id>} [--name <name>] [-state <path>] [--machine_type <cpu>x<mem>] [--background] [--use]


Create an ephemeral cluster:

$ nsc create
  Created new ephemeral environment! ID: me4ev9pm8qk8o

Attach your local Docker to the new environment:

$ nsc docker attach-context --to me4ev9pm8qk8o --name my-remote-docker --background --use
  Attached Docker Context: my-remote-docker

Run Docker commands as usual and use the newly created context:

$ docker compose up



Create a new ephemeral environment. Either --new or --to <cluster-id> must be set.

--to <cluster-id>

Rather than creating a new ephemeral environment, attach to Docker in an existing environment (identified by its id). Either --new or --to <cluster-id> must be set.

--name <name>

The name of the Docker context that is created; by default it will be nsc-{cluster-id}.

--state <path>

Specify a custom directory where the command stores the Docker context configuration.

--machine_type <cpu>x<mem>

Specifying the machine shape when creating a new environment. The following are the supported machine shapes:

  • 2x2: 2 CPU 2 GB memory.
  • 2x4: 2 CPU 4 GB memory.
  • 4x4: 4 CPU 4 GB memory.
  • 4x8: 4 CPU 8 GB memory.
  • 4x16: 4 CPU 16 GB memory.
  • 16x32: 16 CPU 32 GB memory.


If set, attach to the Docker context in the background. So, nsc docker attach-context does not block the caller.


If set, it configures local Docker to use the use the newly configured Docker context.