Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to skip docker image pull #609

Merged
merged 1 commit into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading