#Build dockerfile, and print output to stdout - no publish, no export

1 messages · Page 1 of 1 (latest)

winter mantle
#

Hey everyone 🙂

I have a scenario where I just want to build a dockerfile. I do not want to publish / or export the image built. Simply build it, and print the result to stdout.

When I try to do this, dagger spawns a container and runs the image's entrypoint. Is there a way to avoid this ?

`
import {connect} from "@dagger.io/dagger";

await connect(async (client) => {

const contextDir = await client.host().directory('.');
const webserviceImage = await contextDir.dockerBuild({dockerfile: "testproj/Dockerfile"}).stdout();

}, {LogOutput: process.stdout})
`

wintry topaz
#

That's because of stdout, which refers to the output of the last command that was run. In your case, since you don't have a command explicitly set, it'll execute the default command. After dockerBuild, that's the ENTRYPOINT + CMD. If you don't want to execute that command, you can use .sync() instead.

If the intent was to see the logs from the output process, they should show with dagger run node index.js. If you're not using dagger run then you'll get them from LogOutput: process.stdout, but that output is inferior to the TUI in dagger run.