Dagger 0.9.0 (2023-10-20) Host-to-container, container-to-host, and other networking improvements

Introduction

Service containers have been available since Dagger 0.4, making it easy to run services - like databases or web applications - as ephemeral containers directly inside Dagger.

This first implementation of service containers only supported Container-to-Container (C2C) networking and didn’t allow fine-grained control over the service lifecycle.

Today, we are pleased to announce Dagger 0.9, featuring a significantly improved services API that expands Dagger’s built-in capabilities and brings us closer to the promise of Application Delivery as Code.

This new API adds support for Container-to-Host (C2H) networking, Host-to-Container (H2C) networking, and explicit service lifecycle management.

NOTE: Dagger 0.9 includes a breaking change for binding service containers.

The Container.withServiceBinding API now takes a Service instead of a Container, so you must call Container.asService on its argument.

See the section on binding service containers in our documentation for examples.

Enabling new use cases

With the new services API, it is now possible to expose services running inside a Dagger pipeline to the host and allow Dagger pipelines to access host network resources.

We expect this API to unlock a vast number of new use cases, including but not limited to:

  • Spinning up micro-services or entire development toolchains locally in Dagger, similar to Docker Compose

  • Using AI language models/services on the host from clients running in Dagger

  • Running a web application in Dagger and connecting to it from the host

  • Running an ephemeral database in a pipeline test suite and pointing your local tests at it

  • Accessing resources on internal company networks (such as internal Git repositories) from a Dagger pipeline

  • Connecting to a remote service, which is available via a VPN on the host only

  • Performing DNS resolution through the host

  • Connecting to Docker Desktop on the host from a Dagger pipeline

  • Querying a database on the host from a Dagger pipeline

  • Running integration tests inside a Dagger pipeline that rely on an API server on the host

  • Running services within Dagger (for example, Docker) for a controlled duration of time or even after a pipeline finishes executing-

Let’s take a closer look at the new features.

The following code samples are in Go, but you can find code samples for other languages in our documentation