#Default value for Socket argument (Python SDK)

1 messages · Page 1 of 1 (latest)

gloomy heart
#

Hi, I would like to have a function that mounts the Docker socket in a container. So far I have been able to do that passing the socket via CLI, but I would like to either give a default value or mount it implicitly.

How can I do that?

@function
def client(
    self, docker_socket: dagger.Socket = dag.load_socket_from_id("/var/run/docker.sock")
) -> dagger.Container:
    return (
      dag.container()
      .from_("quay.io/singularity/docker2singularity")
      .with_unix_socket("/var/run/docker.sock", docker_socket)
    )
north geyser
#

i.e: we probably don't want those to be expressed in the module code since that could open the door to some potential vulnerable modues that could abuse this to read sensitive information

gloomy heart
#

I see, thank you! I saw some old examples in Go where ppl used to do sth like dag.Host().UnixSocket("/var/run/docker.sock"), so I was wondering whether something similar was still possible today.

north geyser