#Running Docker's "hello-world" image

1 messages · Page 1 of 1 (latest)

cerulean herald
#

I want to write a quick demo example that matches closely to docker run hello-world

I tried dagger core container from --address=hello-world stdout:

✔ connect 0.5s
✔ loading type definitions 0.8s
✔ parsing command line arguments 0.0s

✔ container: Container! 0.0s
○ .from(address: "hello-world"): Container! 0.8s
✘ .stdout: String! 0.0s
! no command has been set: stdout requires an exec
  1. Why does stdout require an exec?
  2. How can I get the stdout of scratch images like hello-world?
patent tundra
#

Hello @cerulean herald, stdout returns the standard output of the last executed command. If no command has been executed, there is nothing to return. The error is to inform you of that explicitly.

cerulean herald
patent tundra
#

In your example, what you want to do is execute that container's entrypoint with no argument. You can do that with dagger but we make it more explicit.

In dagger shell:

dagger <<.
 container |
 from hello-world |
 with-exec "" --use-entrypoint |
 stdout
.
#

Or using dagger core like you did:

dagger core container from --address=hello-world with-exec --use-entrypoint --args="" stdout

#

I personally prefer the shell syntax because it's more compact 🙂 But both work fine

#

As a one-liner: dagger -c 'container | from hello-world | with-exec "" --use-entrypoint | stdout'

cerulean herald
#

Yeah I agree, the shell example is much more concise, thank you very much