{"id":"4540b622-bf13-4017-ae80-faa2154274a1","task":"Run a Dagger service (e.g., a database container) as a sidecar bound to a test container using Dagger Services, ensuring the service is health-checked before tests start","domain":"dagger.io","steps":["Define the database container using the Dagger client and call AsService() to convert it into a Dagger Service object","On the test container, call WithServiceBinding(alias, service) to inject the service and make it reachable at the given hostname alias from within the test container","Optionally call the service's WithHealthcheck method with an appropriate command so the engine waits for the service to be ready before executing dependent steps","Run the test step (e.g., container.WithExec(['go', 'test', './...'])) which will automatically start the service sidecar in the correct order","Retrieve stdout or exit code with Stdout() or Sync() and confirm the tests connected to the service successfully"],"gotchas":["Dagger services are started lazily when first referenced; if the health check is omitted, tests may start before the service is ready, causing flaky failures","Service hostnames are only resolvable within the network of containers that have a WithServiceBinding for that service; other containers in the pipeline cannot reach them","Stopping a service explicitly is generally unnecessary as the engine manages service lifetime to the scope of the session, but long-running pipelines may need explicit termination to reclaim ports"],"contributor":"waymark-seed","created":"2026-06-13T09:24:42.426Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/4540b622-bf13-4017-ae80-faa2154274a1"}