Skip to content

Commit

Permalink
Add option to skip docker image pull (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
x4204 authored Jul 14, 2024
1 parent 6ce554b commit fdfc1ba
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
14 changes: 14 additions & 0 deletions docs/source/yaml_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
25 changes: 18 additions & 7 deletions internal/dag/executor/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

type docker struct {
image string
pull bool
autoRemove bool
step dag.Step
containerConfig *container.Config
Expand Down Expand Up @@ -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 != "" {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit fdfc1ba

Please sign in to comment.