You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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)
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 enabledifr.RunnerOpts.UseNativeDocker&&!r.RunnerOpts.UseDind {
switch {
casestrings.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")
casestrings.HasPrefix(r.RunnerOpts.DockerHost, "tcp://"):
ctr=ctr.WithEnvVariable("DOCKER_HOST", r.RunnerOpts.DockerHost)
default:
returnnil, 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.
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.
Activity
sipsma commentedon Feb 25, 2024
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)
aweris commentedon Feb 26, 2024
I am using the
socketsupport 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.
As an approach, even currently used
Host()approach is working it has drawbacks as well. I agree, moving toCurrentModulewouldn't be an ideal solution.I think this issue has similar concerns with #6112. What I want is to pass/access the
dockersocket within the function without requiring users to pass it completely since it adds extra complexity.shykes commentedon Apr 27, 2024
This would break the sandbox. #6747 on the other hand is a no-brainer.
sipsma commentedon Apr 28, 2024
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.
shykes commentedon Apr 28, 2024
Oh, got it. Agreed!