#[resolved] - How to get output of the work being done in a container?
1 messages · Page 1 of 1 (latest)
hi! currently at 0.11.1
Have you tried the -v flag for verbose output? I'm not sure it will help you, but it was recently added so that the default output is sort of silent.
hm, it's not exactly what I'm looking for, I'm not for instance getting the stderr of commands that fail within the container
and I'm not getting the stdout of commands other than the last one
Hmm. yeah. I wasn't sure it would help. I'm a Dagger beginner myself. So, sorry I couldn't help.
no problem!
The crew are in the US, so they usually reply in the afternoon.
@red verge there's -d that's more verbose but it includes information about the exchange between the client and dacker backend
[open] - How to get output of the work being done in a contair?
[open] - How to get output of the work being done in a container?
Hey @unique depot
At a high level what you’re looking for is the stdout method that exists on the container type.
could you share your code, there are a few ways to approach this and it will be easier to point you in the right direction with an existing code snippet.
hi! thanks a lot for answering
here's the command that I'm looking to introspect:
dagger -m github.com/Dudesons/daggerverse/infrabox call \
terragrunt \
container \
with-exec --args "apk update"
the stdout function does do this, but it requires a successful run and furthermore it only outputs the stdout of the very last command
Couple things off the top of my head that helped me inspect:
- You can write logs to files in the container itself, which can be output later.
- You can modify the function to return a Container instead of some other value, and have that function stop just before the point where you would run the command that's failing. Then you can invoke
dagger call my-func [flags] terminal, and it will give you a defaultshshell into that container when the function returns. Then you can run the failing command yourself and watch the output/inspect the environment there.
In my case, when a command called through WithExec() fails, at the end of the function I do get the whole log of that command if I've called Stdout(ctx) (Go SDK). I'm pretty sure I get output from earlier commands as well.
Hm let me try that again
If a function returns a container, I think you're just able to call terminal on it to get a shell and try anything you want. Has been super helpful for me.
hm I see, I'll do it in the python sdk, I've been chaining through the command line
terminal is great for debugging, but if you just want to see the output, call stdout as the last argument
Try this
dagger -m github.com/Dudesons/daggerverse/infrabox call \
terragrunt \
container \
with-exec --args "apk update" stdout
I'm very unfamiliar with all the things you can do at the CLI level -- that's great! I only knew to do this via SDKs.
do you get this too?
Yeah that is one of the best parts is basicalluy there ids a 1:1 mapping between what you can do via the CLi and what you can do via the SDK 🙂
Yeah I did but that looks like a separate issue 😄 let me dig a bit
Ah, if you want to do with-exec you have to pass an array of arguments if there is more than one
Check this out to see for yourself (also good to always use the --help whenever you run into issues)
dagger -m github.com/Dudesons/daggerverse/infrabox call \
terragrunt
container
with-exec --help
You should see this at the top
Flags:
--args strings
Command to run instead of the
container's default command
(e.g., ["run", "main.go"]).
If empty, the container's
default command is used.
In that case, I imagine under the hood his command was returning something like command not found, but how do we see more than the exit code here?
Hm sorry I am a bit lost too lets look at the code!
hm that's a good idea any clue where I should look this up?
You can alwys find the source code via the daggerverse: https://daggerverse.dev/mod/github.com/Dudesons/daggerverse/infrabox@41e1f414c163b6676acd03c184d37e3ec8a64b2b
I think the main issue is that when you call with_exec from code you have to pass in an array of strings, but I am not 100% sure how to handle this in the CLI
This is not actually a problem with this speecific module, its the way that with-exec works
This worked for me via the CLI
dagger -m github.com/Dudesons/daggerverse/infrabox call terragrunt container with-exec --args "apk,update" stdout
I think this DX is a bit clunky, we are working on improving it though.
niiiiice! fantastic finally
Specifically, how is someone supposed to know that they need to pass in a list of strings - the way you wrote it initially is how I would have done it too.
the error also was hard to parse
thanks a lot seriously
@subtle coral and also for the debugging tips!
Going back to this, the issue happened at the engine level because it did not know how to execute this command as it was written (via the underlying GraphQL query I think) -- so there is no underlying error message.
Feels like the error mesage from engine should give a bit more hints on whats wrong.
argh i would help out and do this myself if I had the time but i'm rushing and I already half-committed to making a scraper for making a wiki out of this discord
FWIW I found the answer here: https://docs.dagger.io/quickstart/883939/containers/#execute-commands-in-the-container
Because we do have one example in the docs where we call with-exec but I think the --help should not show the array because that through me off too.