# `ContainerImage`

A container image's whole name: `docker.io/library/nginx:1.27`.

Use it for what a service runs. For a shipping container, use [`ContainerNumber`](/docs/types/type-container-number.md).

## Shape

One value, held as text in one set form, with no parts: `registry.example.com:8443/a/b/c:latest@sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b`.

## Example

```jadpo
ContainerImage("docker.io/library/nginx:1.27")
```

`ContainerImage(raw)` checks the text, and text that isn't one breaks the `format` rule.

`text.parse(raw, as: ContainerImage)` reads one from text that comes from outside. Text that isn't one at all fails `malformed`, such as `nginx:1.27`, `library/nginx:1.27` or `docker.io/library/nginx`.

## Good to know

- It needs its registry, so `nginx:1.27` is refused.
- `==` tells you whether two are the same. `<` and `list.sort_by` don't take it.

## In JSON

A string, in a request, a response or `json.write`:

```json
"docker.io/library/nginx:1.27"
"ghcr.io/acme/shop-api@sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b"
"localhost:5000/infra/web_app:v2.1.0-rc.1"
```

## Details

<details>
<summary>Text form, storage, how it is shown, and operations</summary>

`ContainerImage` is in the group Software, and has been in Jadpo since 0.1.0.

### Text form

`text.from` writes one standard text form, the same form `text.parse` reads back: `docker.io/library/nginx:1.27`, `ghcr.io/acme/shop-api@sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b` and `localhost:5000/infra/web_app:v2.1.0-rc.1`.

### How it is stored

It is stored in one column named for the field, of type `text`. `localhost:5000/infra/web_app:v2.1.0-rc.1` is stored as `'localhost:5000/infra/web_app:v2.1.0-rc.1'`.

### How it is shown to people

`text.format(value, locale:)` shows it to people in their locale.

With `locale: Locale.en_gb`:

| Value | Shown |
|---|---|
| `docker.io/library/nginx:1.27` | `docker.io/library/nginx:1.27` |
| `ghcr.io/acme/shop-api@sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b` | `ghcr.io/acme/shop-api@sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b` |
| `localhost:5000/infra/web_app:v2.1.0-rc.1` | `localhost:5000/infra/web_app:v2.1.0-rc.1` |
| `registry.example.com:8443/a/b/c:latest@sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b` | `registry.example.com:8443/a/b/c:latest@sha256:6c3c624b58dbbcd3c0dd82b4c53f04194d1247c6eebdaab7c610cf7d66709b3b` |

### Operations

It also takes `text.parse`, `text.from`, `text.format`, `json.read`, `json.write` and `==`. [How every standard type behaves](/docs/every-standard-type-meets-one-contract.md) says how they work.

</details>
