I'm trying to use WithHostname because serviceBinding isn't the right solution to handle services in the DockerSDK.
However, it seems my services are not reachables and I do not understand why... Here's a simple repro:
package main
import (
"context"
"dagger/test/internal/dagger"
)
type Test struct{}
func (t *Test) Test(ctx context.Context) *dagger.Container {
_, err := dag.Container().
From("redis:alpine").
WithEnvVariable("ALLOW_EMPTY_PASSWORD", "yes").
WithExposedPort(6379).
AsService(dagger.ContainerAsServiceOpts{UseEntrypoint: true}).
WithHostname("redis").
Start(ctx)
if err != nil {
panic(err)
}
secondService := dag.Container().From("alpine").WithExec([]string{"apk", "add", "redis"})
return secondService
}
$ dagger call test terminal
x> redis-cli -h redis
Could not connect to Redis at redis:6379: Name does not resolve
It works if I try with service binding, and according to the test in Dagger (https://github.com/dagger/dagger/blob/6227e68b9a484890a7494eb879d711cebb477e60/core/integration/services_test.go#L169), I would expect my test to work 😦
are you using it from the IDE or CLI?