Repository: UKGovernmentBEIS/inspect_ai
Issue: Unable to identify docker project for a given sample
Root cause: Unimplemented Feature Gap

When running multiple samples the names of docker projects are not distinguishable and so debugging is hard. As far as I can tell, I cannot control this value. Including `Sample.id` in the name would help.

I believe this would require updating `sample_init` in `src/inspect_ai/util/_sandbox/docker/docker.py`.

<img width="337" alt="Image" src="https://github.com/user-attachments/assets/a451b814-df9e-41f3-90e7-8a6c86e6380a" />



My current workaround is adding `logger.info("project.name: %s", project.name)` to `src/inspect_ai/util/_sandbox/docker/docker.py` so I can lookup the docker project by sample

One piece of counterpressure on this is that we want to keep the names of Docker projects short for display in the UI and copying/pasting for `docker exec -it`. In many cases sample IDs can be very long (up to 100 characters).  If you look on the **Running Samples** tab in the task display then click the sample info box at the top (as shown here: https://inspect.ai-safety-institute.org.uk/tools.html#vnc-client) you'll get the container Id for the sample. 

Does that give you the workflow that you'd want? All things being equal I'd rather rely on this for debugging than making the project name larger.

That workflow works for `inspect eval ...` but I have some e2e tests which look like

```python
from inspect_ai import Task, eval

@pytest.mark.slow
def test_run_solutions(self) -> None:
    eval(Task(...))
```

and `pytest` doesn't show the container per sample.

I found a work-around by adding:

```python
@task
def test_reference_solutions() -> Task:
    return Task(
```

and `inspect eval my_eval/tests/my_test.py`


It's not a complete solution for my workflow, as I run with `--no-sandbox-cleanup` and want to access the containers after execution, but the final output doesn't identify the samples:

```
┌────────────────────────────────────────────┬─────────────────────────────────────────────────────────────┐
│ Container(s)                               │ Cleanup                                                     │
╞════════════════════════════════════════════╪═════════════════════════════════════════════════════════════╡
│ inspect-test_referen-iuyucul-default-1     │ inspect sandbox cleanup docker inspect-test_referen-iuyucul │
│ inspect-test_referen-iuyucul-web_browser-1 │                                                             │
├────────────────────────────────────────────┼─────────────────────────────────────────────────────────────┤
│ inspect-test_referen-i9ksmj5-default-1     │ inspect sandbox cleanup docker inspect-test_referen-i9ksmj5 │
│ inspect-test_referen-i9ksmj5-web_browser-1 │                                                             │
├────────────────────────────────────────────┼─────────────────────────────────────────────────────────────┤
│ inspect-test_referen-iku4brr-default-1     │ inspect sandbox cleanup docker inspect-test_referen-iku4brr │
│ inspect-test_referen-iku4brr-web_browser-1 │                                                             │
├────────────────────────────────────────────┼─────────────────────────────────────────────────────────────┤
│ inspect-test_referen-icjajrh-default-1     │ inspect sandbox cleanup docker inspect-test_referen-icjajrh │
│ inspect-test_referen-icjajrh-web_browser-1 │                                                             │
└────────────────────────────────────────────┴─────────────────────────────────────────────────────────────┘
```

Adding sample ids to this table would address my use case.

Does this do it? https://github.com/UKGovernmentBEIS/inspect_ai/pull/1362



Unfortunately not, I see a generated sample id which is different from the one I pass to `Sample(id=...`

<img width="487" alt="Image" src="https://github.com/user-attachments/assets/037a35d2-d2f8-4a39-8ae5-4947bbee0cf6" />

```
Docker Sandbox Environments (not yet cleaned up):                          
┌────────────────────────┬───────┬────────────────────────────────────────┐
│ Sample ID              │ Epoch │ Container(s)                           │
╞════════════════════════╪═══════╪════════════════════════════════════════╡
│ YJGm6R7hLmRUY44xcE22Qt │ 1     │ inspect-test_referen-i5kjjdp-default-1 │
├────────────────────────┼───────┼────────────────────────────────────────┤
│ 66winYMS7kWLVGrS7mxtfr │ 1     │ inspect-test_referen-inabap5-default-1 │
└────────────────────────┴───────┴────────────────────────────────────────┘
```

I see that as well! Will fix ASAP.

okay, resolved here: https://github.com/UKGovernmentBEIS/inspect_ai/pull/1389

It works! Thank you :)