> This page is for version 0.5.1.
> For other versions, use one of these documentation indexes:
> - Main (default): https://docs.nvidia.com/nemo/gym/main/llms.txt
> - 0.7.0: https://docs.nvidia.com/nemo/gym/v0.7.0/llms.txt
> - 0.6.0: https://docs.nvidia.com/nemo/gym/v0.6.0/llms.txt
> - 0.5.1: https://docs.nvidia.com/nemo/gym/v0.5.1/llms.txt
> - 0.5.0: https://docs.nvidia.com/nemo/gym/v0.5.0/llms.txt
> - 0.4.0: https://docs.nvidia.com/nemo/gym/v0.4.0/llms.txt
> - 0.3.0: https://docs.nvidia.com/nemo/gym/v0.3.0/llms.txt
> - 0.2.1: https://docs.nvidia.com/nemo/gym/v0.2.1/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/gym/_mcp/server.

# nemo_gym.sandbox.compose_config

Turn a published Harbor Compose overlay into a document the sandbox Compose adapter can start.

Harbor publishes `environment/docker-compose.yaml` as an overlay on its own base file: the
`main` service is the task image, sidecars are prebuilt images. Starting it without Docker
needs each image's recorded OCI configuration (entrypoint, command, user, exposed ports,
healthcheck), which `image_configs` supplies, keyed by image reference.

Adapted from Gym's Terminal Bench 4 server (`resources_servers/terminal_bench_4/compose_config.py`).

## Module Contents

### Functions

| Name                                                                                  | Description                                                                                                   |
| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| [`_compose_literals`](#nemo_gym-sandbox-compose_config-_compose_literals)             | -                                                                                                             |
| [`_peer_url`](#nemo_gym-sandbox-compose_config-_peer_url)                             | Whether `value` is exactly one URL whose host is a Compose service, the shape `resolve_environment` rewrites. |
| [`adapt_non_root_sidecars`](#nemo_gym-sandbox-compose_config-adapt_non_root_sidecars) | Keep a sidecar on its image's default non-root user without host-file injection.                              |
| [`opensandbox_shm_labels`](#nemo_gym-sandbox-compose_config-opensandbox_shm_labels)   | OpenSandbox takes a service's shared-memory size as a label. Mutates and returns `document`.                  |
| [`resolve_compose`](#nemo_gym-sandbox-compose_config-resolve_compose)                 | Apply Harbor's prebuilt-image base and normalize the published task overlay.                                  |

### API

```python
nemo_gym.sandbox.compose_config._compose_literals(
    value: typing.Any
) -> typing.Any
```

```python
nemo_gym.sandbox.compose_config._peer_url(
    value: typing.Any,
    services: dict
) -> bool
```

Whether `value` is exactly one URL whose host is a Compose service, the shape `resolve_environment` rewrites.

A compound value (Kafka's comma-separated `KAFKA_ADVERTISED_LISTENERS`) parses to a hostname too, but
its port text is not a number and the adapter would fail reading it; it is left as written.

```python
nemo_gym.sandbox.compose_config.adapt_non_root_sidecars(
    document: dict,
    image_configs: dict
) -> dict
```

Keep a sidecar on its image's default non-root user without host-file injection.

A non-root process cannot edit `/etc/hosts`, so peer names are resolved into the
environment variables that carry `http://&lt;service&gt;` URLs instead, and the explicit
`user` copied from image metadata is dropped so the provider does not try to `su`
to the user it already runs as. Mutates and returns `document`.

```python
nemo_gym.sandbox.compose_config.opensandbox_shm_labels(
    document: dict,
    label: str = 'nemo.nvidia.com/shm'
) -> dict
```

OpenSandbox takes a service's shared-memory size as a label. Mutates and returns `document`.

```python
nemo_gym.sandbox.compose_config.resolve_compose(
    document: dict,
    main_image: str,
    image_configs: dict
) -> dict
```

Apply Harbor's prebuilt-image base and normalize the published task overlay.