#Published image does not have CMD set

1 messages · Page 1 of 1 (latest)

dry nacelle
#

Hi everyone,

I am using Dagger to create a couple of Docker images in a Jenkins pipeline. My code is structured as follows:

  • BuildEnv method: This method creates the Docker image using From, WithExec, and WithDefaultTerminalCmd.
  • Publish method: This method publishes the container returned by the BuildEnv method.

The container I'm building in the BuildEnv method has an entrypoint that I previously set in the Dockerfile using the CMD directive. I assumed that WithDefaultTerminalCmd in Dagger would function the same as CMD, but it doesn't seem to work as expected. When I run the container, it immediately exits without executing the entrypoint, which is a simple shell script

toxic pelican
#

you can use the entrypoint by setting the UseEntrypoint arg on WithExec and family
But not sure about Terminal - cc @thick shuttle

dry nacelle
#

I cannot use the entrypoint unfortunately that's why I was looking to use CMD

thick shuttle
#

To execute CMD, you need a Container.withExec, with empty arguments:

ctr.WithExec([]string{})
dry nacelle
#

That makes sense. I didn't even see the WithDefaultArgs method. Thank you very much, I'll try it immediately