diff --git a/docs/source/yaml_format.rst b/docs/source/yaml_format.rst index d2d2e84c5..562cc1269 100644 --- a/docs/source/yaml_format.rst +++ b/docs/source/yaml_format.rst @@ -226,6 +226,20 @@ Example Log output: .. image:: https://raw.githubusercontent.com/yohamta/dagu/main/examples/images/docker.png +By default, Dagu will try to pull the Docker image. For images built locally this will fail. If you want to skip image pull, pass :code:`pull: false` in executor config. + +.. code-block:: yaml + + steps: + - name: deno_hello_world + executor: + type: docker + config: + image: "denoland/deno:1.10.3" + pull: false + autoRemove: true + command: run https://examples.deno.land/hello-world.ts + You can config the Docker container (e.g., `volumes`, `env`, etc) by passing more detailed options. diff --git a/internal/dag/executor/docker.go b/internal/dag/executor/docker.go index 248f00693..949bc9a44 100644 --- a/internal/dag/executor/docker.go +++ b/internal/dag/executor/docker.go @@ -20,6 +20,7 @@ import ( type docker struct { image string + pull bool autoRemove bool step dag.Step containerConfig *container.Config @@ -57,13 +58,15 @@ func (e *docker) Run() error { } defer cli.Close() - reader, err := cli.ImagePull(ctx, e.image, types.ImagePullOptions{}) - if err != nil { - return err - } - _, err = io.Copy(e.stdout, reader) - if err != nil { - return err + if e.pull { + reader, err := cli.ImagePull(ctx, e.image, types.ImagePullOptions{}) + if err != nil { + return err + } + _, err = io.Copy(e.stdout, reader) + if err != nil { + return err + } } if e.image != "" { @@ -167,7 +170,15 @@ func newDocker( } } + pull := true + if p, ok := execCfg.Config["pull"]; ok { + if p, ok := p.(bool); ok { + pull = p + } + } + exec := &docker{ + pull: pull, step: step, stdout: os.Stdout, containerConfig: containerConfig,