nsc expose

Expose an exported port on a running container.

expose opens a public ingress to an exported port on a running container. The provided container needs to be up and running. For example, it can be started in advance using docker run within an ephemeral cluster. The exposed endpoint is encrypted with TLS and secured with Namespace authentication, so whoever has access to the workspace where the ephemeral environment was created in, will also have access to the endpoint.

Currently possible to expose only HTTP services.


nsc expose <cluster-id> --container <name> [--container_port <port[,port]>] [--prefix <url-prefix> [--source <docker|containerd> [--output <plain|json>]


In the example below we first create an ephemeral cluster, then SSH into the cluster, start the nginx container with docker run command and then expose it using nsc expose.

Create an ephemeral cluster:

$ nsc create
Created cluster "oiepencpc41im"
 deadline: 2023-04-25T09:46:03Z

SSH into the created cluster:

$ nsc ssh oiepencpc41im

and start nginx container within the created cluster:

oiepencpc41im:~# docker run --name nginx-foobar -p 80:80 -d nginx

Afterwards expose port 80 using nsc expose command:

$ nsc expose oiepencpc41im --container nginx-foobar --container_port 80
Exported port 80 from nginx-foobar (20e97bc453c936a9665dd6ce75e0168c92a689cc92214303a87fc19a):

Now you can visit the provided URL https://nginx-foobar-j239700-oiepencpc41im.fra1.nscluster.cloud in you browser and use your Namespace credentials for authentication.


--container <name>

To specify a name of a container to expose. This option is required.

--container_port <port[,port]>

Exports the specified ports (separated by commas) as public ingresses. If the option is not provided, all the exported ports would be exposed.

--prefix <prefix>

Adds a prefix to the allocated URL.

--source <source>

To specify the container runtime which was used to run the container. Supported options are docker and containerd. By default docker is used to lookup running containers.

-o <type>

Specifying expose command output format. Supported options are json and plain. By default plain output format is used.