Hi Dagger community, I apologize ahead of time if this question has been asked, I imagine it's come up before. I searched Discord for "shell into running pipeline container", "terminal in running container", but couldn't find my question/answer.
I'm coming from a Docker/Compose background where I can simply call:
docker exec -it <container> /bin/bashto shell into a container and run troubleshooting commands like ls <dir> or cat <file>. I can't find how to do this in Dagger yet.
For example, I don't see any of these containers running, I'm shocked that I get no results running the commands below while a dagger -c <function>is running. I have no clue where these containers are.
docker psctr containers lscrictl ps
I can however, chain a Terminal() ,but it requires me to modify the Dagger module. Another option I've discovered is using dagger shell, and use the pipe, i.e. .myfunction | terminal. Is there adagger CLI command for this?
My exact use case is trying to troubleshoot the filesystem in a similar module as k3s Server function. I want to shell into the running Kubernetes k3s container and browse the filesystem. but I am unable to chain a Terminal() to the:
func (m *Kube) Server() *dagger.Service {
return m.Container.
AsService(dagger.ContainerAsServiceOpts{
Args: []string{
"sh", "-c",
"k3s server --debug --bind-address $(ip route | grep src | awk '{print $NF}') --tls-san kubeapi --disable traefik --disable metrics-server --egress-selector-mode=disabled",
},
InsecureRootCapabilities: true,
UseEntrypoint: true,
}).
//doesnt work here
//Terminal().
WithHostname("kubeapi")
}
I get the error:
./main.go:103:3: m.Container.AsService(dagger.ContainerAsServiceOpts{…}).Terminal undefined (type *dagger.Service has no field or method Terminal)
Thank you in advance.