Skip to content

Add socket support to CurrentModule #6726

Closed

Description

@sipsma

We missed adding support for host sockets to CurrentModule when removing Host from module codegen. We should re-add the equivalent support, it should be pretty straightforward.

Activity

  1. modified the milestones: v0.10.0, v0.10.x on Feb 23, 2024
  2. sipsma commented on Feb 25, 2024

    @sipsma
    ContributorAuthor

    I realized that this actually is quite debatable in terms of whether we should support it.

    The problem is that a unix socket is only valid for the duration of the function's container. There are situations in which that would be fine, but if a function returns anything that has such a unix socket anywhere in its DAG, then evaluating that will result in an error or unexpected behavior like using a unix socket from the path of a different container (or the host). In theory, perhaps we could support this and return an error if the user module tries to return something that references the socket, but something about that feels very confusing and surprising relative to not supporting it in the first place.

    @aweris can you describe and/or link to where you had a need for this previously? Ideally I think we may just want to figure out a different approach.

    (also moved this off the v0.10.0 milestone to v0.10.x pending a decision on whether to actually implement this)

  3. aweris commented on Feb 26, 2024

    @aweris
    Contributor

    I am using the socket support to configure the docker CLI. This is currently the fastest and most stable way to execute docker inside Dagger.

    Example code how I configure it.

        // configure docker using docker host when docker is enabled and DinD is not enabled
        if r.RunnerOpts.UseNativeDocker && !r.RunnerOpts.UseDind {
            switch {
            case strings.HasPrefix(r.RunnerOpts.DockerHost, "unix://"):
                dh := strings.TrimPrefix(r.RunnerOpts.DockerHost, "unix://")
    
                ctr = ctr.WithUnixSocket("/var/run/docker.sock", dag.Host().UnixSocket(dh))
                ctr = ctr.WithEnvVariable("DOCKER_HOST", "unix:///var/run/docker.sock")
            case strings.HasPrefix(r.RunnerOpts.DockerHost, "tcp://"):
                ctr = ctr.WithEnvVariable("DOCKER_HOST", r.RunnerOpts.DockerHost)
            default:
                return nil, fmt.Errorf("unsupported docker host: %s", r.RunnerOpts.DockerHost)
            }
        }

    I realized that this actually is quite debatable in terms of whether we should support it.

    As an approach, even currently used Host() approach is working it has drawbacks as well. I agree, moving to CurrentModule wouldn't be an ideal solution.

    I think this issue has similar concerns with #6112. What I want is to pass/access the docker socket within the function without requiring users to pass it completely since it adds extra complexity.

  4. shykes commented on Apr 27, 2024

    @shykes
    Contributor

    This would break the sandbox. #6747 on the other hand is a no-brainer.

  5. sipsma commented on Apr 28, 2024

    @sipsma
    ContributorAuthor

    This would break the sandbox

    The idea is that a unix sock created in a function could still work as something passed around. It's not to support using arbitrary unix socks on the host. As I mentioned here there's a lot to deal with if we wanted to support it, which is why #6747 is the priority.

  6. shykes commented on Apr 28, 2024

    @shykes
    Contributor

    Oh, got it. Agreed!

  7. removed this from the next milestone on Apr 28, 2024
  8. added
    area/engine
    and removed on Jul 6, 2024
  9. locked and limited conversation to collaborators on Mar 24, 2026
  10. converted this issue into a discussion #12346 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

    area/enginearea/engine/api

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions