I can't get files exported from containers which are bound using WithServiceBinding, is this not possible?
When I attempt to export a dir, or get content of a file, from the service it always runs its entrypoint script, causing it to start its services.
To reproduce I created a script which also does not properly run but shows my intent:
func main() {
ctx := context.Background()
client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
log.Fatalln(err)
}
defer func(client *dagger.Client) {
err := client.Close()
if err != nil {
log.Println(err)
}
}(client)
cntSvc := client.Container().From("alpine").
WithExec([]string{"apk", "update"}).
WithExec([]string{"apk", "add", "netcat-openbsd"}).
WithEnvVariable("time", time.Now().String()).
WithExec([]string{"sh", "-c", "echo \"${time}\" > /tmp/test"}).
WithEntrypoint([]string{"nc"}).
WithDefaultArgs(dagger.ContainerWithDefaultArgsOpts{Args: []string{"-l", "-p", "8080"}}).
WithExposedPort(8080).
WithExec(nil)
_, _ = client.Container().From("alpine").
WithExec([]string{"sh", "-c", "echo 1"}).
WithServiceBinding("serviceCnt", cntSvc).
// ERROR exec sh -c echo 2
//┃ │ host alias: lookup s1jn3amhp8uem on 10.87.0.1:53: no such host
WithExec([]string{"sh", "-c", "echo 2"}).
Sync(ctx)
content2, err := cntSvc.File("/tmp/test").Contents(ctx)
if err != nil {
log.Fatalln(err)
}
log.Println("this does not work: ", content2)
}