Skip to content

Using Services in multiple containers results in network issues #6951

Closed

Description

@kpenfound

This appears to be a regression introduced in 0.10.2, things work as expected in 0.10.1

From @nipuna-perera on Discord:

Basically run (container A + service).

file = get file from (container A + service)

Try to run (container B + file) fails with:

host alias: lookup t6sjv1ru3serq on 10.87.0.1:53: no such host
  ┃ lookup t6sjv1ru3serq.c1mh4mk35essm.dagger.local on 10.87.0.1:53: no such host

Activity

  1. kpenfound commented on Mar 27, 2024

    @kpenfound
    ContributorAuthor

    Repro:

    func (r *Repro) Run(ctx context.Context) *Container {
    	redis := dag.Container().
    		From("redis").
    		WithExposedPort(6379).
    		AsService()
    	cli := dag.Container().
    		From("redis").
    		WithoutEntrypoint().
    		WithServiceBinding("redis", redis)
    
    	ctrA := cli.WithExec([]string{"sh", "-c", "redis-cli -h redis info >> /tmp/out.txt"})
    
    	file := ctrA.Directory("/tmp").File("/out.txt")
    
    	ctrB := dag.Container().
    		From("alpine").
    		WithFile("/out.txt", file)
    
    	return ctrB.WithExec([]string{"cat", "/out.txt"})
    }

    dagger call run

    on v0.10.1:

    Container evaluated. Use "dagger call run --help" to see available sub-commands.
    

    on v0.10.2:

    ✔ Repro.run: Container! 5.1s
      ✔ Container.directory(path: "/tmp"): Directory! 3.2s
        ● start docker-entrypoint.sh redis-server 9.3s
        ┃ 17:C 27 Mar 2024 13:08:02.780 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled
        ┃ an also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.
        ┃ nd then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
        ┃ 17:C 27 Mar 2024 13:08:02.781 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
        ┃ 17:C 27 Mar 2024 13:08:02.781 * Redis version=7.2.4, bits=64, commit=00000000, modified=0, pid=17, just started
        ┃ 17:C 27 Mar 2024 13:08:02.781 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
        ┃ 17:M 27 Mar 2024 13:08:02.781 * monotonic clock: POSIX clock_gettime
        ┃ 17:M 27 Mar 2024 13:08:02.782 * Running mode=standalone, port=6379.
        ┃ 17:M 27 Mar 2024 13:08:02.782 * Server initialized
        ┃ 17:M 27 Mar 2024 13:08:02.782 * Ready to accept connections tcp
    ✘ Container.sync: ContainerID! 5.3s
      ✘ exec cat /out.txt 5.1s
      ┃ host alias: lookup i3f462iju6h70 on 10.87.0.1:53: no such host
      ┃ lookup i3f462iju6h70.uhbgnlc0u1b68.dagger.local on 10.87.0.1:53: no such host
    
    Error: response from query: input: container.from.withFile.withExec.sync resolve: process "cat /out.txt" did not complete successfully: exit code: 125
    
  2. jedevc commented on Mar 27, 2024

    @jedevc
    Contributor

    May be fixed by #6914 - cc @vito

  3. vikram-dagger commented on Apr 2, 2024

    @vikram-dagger
    Contributor

    I'm also running into this issue when trying to build a Spring app which uses testcontainers.

    Repro

    git clone https://github.com/spring-projects/spring-petclinic.git
    cd spring-petclinic
    dagger init
    dagger develop --sdk=go
    dagger install github.com/levlaz/daggerverse/[email protected]
    dagger install github.com/jcsirot/daggerverse/java@250eb3e0f49da321cca2241fe1e1d017b4143a91
    dagger install github.com/shykes/daggerverse/docker@3338120927f8e291c4780de691ef63a7c9d825c0
    

    Module

    package main
    
    import (
        "context"
        "dagger/spring-petclinic/internal/dagger"
    )
    
    type SpringPetclinic struct{}
    
    func (m *SpringPetclinic) Build(ctx context.Context, source *Directory) (string, error) {
    
        mariadb := dag.Mariadb().Serve(dagger.MariadbServeOpts{Version: "10.11.2", DbName: "petclinic"})
    
        dockerd := dag.Docker().Engine()
    
        app := dag.Java().WithJdk("17").WithMaven("3.9.5").WithProject(source.WithoutDirectory("dagger")).Maven([]string{"-Dspring.profiles.active=mysql", "clean", "package"})
    
        build := app.WithServiceBinding("db", mariadb).
            WithServiceBinding("docker", dockerd).
            WithEnvVariable("MYSQL_URL", "jdbc:mysql://db/petclinic").
            WithEnvVariable("MYSQL_USER", "root").
            WithEnvVariable("MYSQL_PASS", "")
            //WithExec([]string{"mvn", "-X", "-Dspring.profiles.active=mysql", "clean", "package"})
    
        deploy := dag.Container().
            From("eclipse-temurin:17-alpine").
            WithDirectory("/app", build.Directory("./target")).
            WithEntrypoint([]string{"java", "-jar", "-Dspring.profiles.active=mysql", "/app/spring-petclinic-3.0.0-SNAPSHOT.jar"})
    
        address, err := deploy.Publish(ctx, "ttl.sh/myapp")
        if err != nil {
            return "", err
        }
        return address, nil
    }
    
    dagger call build --source=.
    
  4. kpenfound commented on Apr 18, 2024

    @kpenfound
    ContributorAuthor

    My above repro is fixed on 0.11.1. Is yours fixed as well @vikram-dagger ?

  5. sagikazarmark commented on Apr 26, 2024

    @sagikazarmark
    Contributor

    Not sure if it's related, but this started failing for me again:

    dagger call -m github.com/sagikazarmark/daggerverse/helm/tests login-and-push
  6. jasonmccallister commented on Feb 13, 2025

    @jasonmccallister
    Contributor

    Still seeing this today (reported in Discord Help), but I'm unable to reproduce given the examples above, and trying the example here:

    func (m *DnsError) Test(
    	ctx context.Context,
    	// +optional
    	// +defaultPath="/"
    	dir *dagger.Directory,
    	// +optional
    	// +default=50
    	times int,
    	// +optional
    	// +default=10
    	count int,
    ) error {
    	mongodb := dag.Container().From("mongo:latest").
    		WithEnvVariable("MONGO_INITDB_ROOT_USERNAME", "admin").
    		WithEnvVariable("MONGO_INITDB_ROOT_PASSWORD", "password").
    		WithExposedPort(27017).
    		AsService(dagger.ContainerAsServiceOpts{
    			UseEntrypoint: true,
    		})
    
    	// write a for loop that creates a new container and execs a command to ping the mongodb service
    	for i := 0; i < times; i++ {
    		ctr := dag.Container().
    			From("alpine:3").
    			WithEnvVariable("CACHE_BUST", time.Now().Format("20060102150405")).
    			WithDirectory("/outputs/tests", dir).
    			WithMountedDirectory("/output/data", dir).
    			WithServiceBinding("mongodb", mongodb)
    
    		out, err := ctr.WithExec([]string{"ping", "-c", fmt.Sprintf("%d", count), "mongodb"}).Stdout(ctx)
    		if err != nil {
    			fmt.Println(err)
    			continue
    		}
    
    		_ = ctr.WithNewFile("/outputs/content", out).Directory("/outputs")
    
    	}
    
    	return nil
    }
  7. locked and limited conversation to collaborators on Mar 24, 2026
  8. converted this issue into a discussion #12334 on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions