# Using artifact images

> For AI agents: the complete documentation index is at https://buddy.works/llms.txt

Run a BUILD action or a service on a Docker image stored in a Buddy Container Image artifact. Set image_location to ARTIFACT_REGISTRY, grant Read-only access.

Container images stored in Container Image artifacts can be used as execution environments for `BUILD` actions or as images for custom services. The pipeline pulls images from `container.registry.sh` without requiring separate authentication credentials. The pipeline must have at least the **Read-only** permission level for the artifact.

## Artifact images in build actions

In the action YAML, set `image_location: ARTIFACT_REGISTRY` and specify the artifact and the version, which is the image tag:

```yaml
- action: Build on artifact image
  type: BUILD
  image_location: ARTIFACT_REGISTRY
  artifact: my-app-image
  version: 1.1.0
  commands: |-
    cat /etc/os-release | head -2
    uname -m
```

You do not need the `docker_image_name` and `docker_image_tag` fields: the image comes from `artifact`, and the tag from `version`. The beginning of the action log shows the image being pulled by its full address, for example `container.registry.sh/my-workspace/my-app-image:1.1.0`.

![BUILD action running on an artifact image](https://buddy.works/docs/artifacts/artifact-image-build-log.png)

The image gets into the registry with a regular `docker push`, described on the [Container registry](https://buddy.works/docs/artifacts/container-registry.md) page.

## Artifact images in custom services

A service, for example your own database or a mock API, uses the same three fields. Add it in the `services` section of the BUILD action as `type: CUSTOM`:

```yaml
- action: Test against service
  type: BUILD
  docker_image_name: library/ubuntu
  docker_image_tag: "24.04"
  commands: |-
    getent hosts my-service
  services:
  - type: CUSTOM
    image_location: ARTIFACT_REGISTRY
    artifact: my-app-image
    version: 1.1.0
    connection:
      host: my-service
    inline_commands: sleep 120
```

The action connects to the service by the host name from `connection.host`. In the example, `getent hosts my-service` returns the IP address of the service container.

The `inline_commands` field is the command the service container starts with. The service is available as long as this command runs, which is why the example uses `sleep 120`.

> **Warning**
>
> The `inline_commands` field accepts a single command. Specifying multiple commands on separate lines or separating them with `;` causes the service container to terminate immediately, even if the action log indicates that the service has started. To execute multiple commands, combine them using `sh -c`:
>
> ```yaml
> inline_commands: sh -c 'echo ready > /tmp/status && sleep 120'
> ```

Other service settings, such as ports and cache, are described in [Custom services](https://buddy.works/docs/actions/services-and-databases/custom.md).

## Pipeline permissions

The pipeline needs at least the **Read-only** level in the artifact's **Permissions** tab. Without it, the action fails before the image is pulled:

```
Pipeline is not allowed to use artifact: my-app-image [BE2810035]
```

If the **All pipelines** row in the artifact's **Permissions** tab has the **Deny** level, add the selected pipeline with the **+** button and set it to **Read-only**.

![Read-only access for a single pipeline](https://buddy.works/docs/artifacts/artifact-image-pipeline-access.png)

## Image tags and version immutability

The `version` field references an image tag rather than an image digest. Image tags in the registry can be overwritten by subsequent `docker push` operations. Using a unique tag for each published image prevents unintended replacements, provided that existing tags are not reused.

See also:

- [Container registry](https://buddy.works/docs/artifacts/container-registry.md) - registry login, pushing and pulling images
- [Permissions and access](https://buddy.works/docs/artifacts/permissions-and-access.md) - access levels for pipelines and sandboxes
- [Custom services](https://buddy.works/docs/actions/services-and-databases/custom.md) - configuring services in the BUILD action
- [Troubleshooting](https://buddy.works/docs/artifacts/troubleshooting.md) - error messages and their causes


---
Original source: https://buddy.works/docs/artifacts/using-artifact-images