> This page is for version 0.4.0.
> 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.tasks.harbor.dockerfile

Recognize Dockerfiles that only name a base image.

Many tasks ship a Dockerfile that is `FROM &lt;image&gt;` plus `WORKDIR`, `ENV`,
`USER` or `LABEL` lines. Nothing in such a file changes the filesystem, so Gym
can run the base image directly and apply the recorded settings at sandbox creation
instead of building. Anything else (`RUN`, `COPY`, `ADD`, multi-stage builds,
`ARG`-templated images) needs a real build, which is not part of this loader yet.

## Module Contents

### Classes

| Name                                                       | Description                                                            |
| ---------------------------------------------------------- | ---------------------------------------------------------------------- |
| [`BaseImage`](#nemo_gym-tasks-harbor-dockerfile-BaseImage) | A Dockerfile that reduces to a base image plus creation-time settings. |

### Functions

| Name                                                                   | Description                                                                |
| ---------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| [`_logical_lines`](#nemo_gym-tasks-harbor-dockerfile-_logical_lines)   | Join continuations without inventing whitespace; drop comments and blanks. |
| [`_parse_env`](#nemo_gym-tasks-harbor-dockerfile-_parse_env)           | -                                                                          |
| [`base_image_only`](#nemo_gym-tasks-harbor-dockerfile-base_image_only) | Return faithfully interpreted settings, or `None` when a build is needed.  |

### Data

[`_ALLOWED_INSTRUCTIONS`](#nemo_gym-tasks-harbor-dockerfile-_ALLOWED_INSTRUCTIONS)

[`_ENV_KEY`](#nemo_gym-tasks-harbor-dockerfile-_ENV_KEY)

### API

```python
class nemo_gym.tasks.harbor.dockerfile.BaseImage(
    image: str,
    workdir: str | None = None,
    env: dict[str, str] = dict(),
    user: str | None = None
)
```

Dataclass

A Dockerfile that reduces to a base image plus creation-time settings.

**`env`** `dict[str, str] = field(default_factory=dict)`

---

**`image`** `str`

---

**`user`** `str | None = None`

---

**`workdir`** `str | None = None`

---

```python
nemo_gym.tasks.harbor.dockerfile._logical_lines(
    text: str
) -> list[str]
```

Join continuations without inventing whitespace; drop comments and blanks.

```python
nemo_gym.tasks.harbor.dockerfile._parse_env(
    arguments: str
) -> dict[str, str] | None
```

```python
nemo_gym.tasks.harbor.dockerfile.base_image_only(
    text: str
) -> nemo_gym.tasks.harbor.dockerfile.BaseImage | None
```

Return faithfully interpreted settings, or `None` when a build is needed.

Variable expansion and relative working directories depend on the base image's
configuration. Leave those to a real build until that configuration is available.

```python
nemo_gym.tasks.harbor.dockerfile._ALLOWED_INSTRUCTIONS = {'FROM', 'WORKDIR', 'ENV', 'USER', 'LABEL'}
```

```python
nemo_gym.tasks.harbor.dockerfile._ENV_KEY = re.compile('[A-Za-z_][A-Za-z0-9_]*')
```