diff --git a/README.md b/README.md index 7639cfd64..c5df6ba89 100644 --- a/README.md +++ b/README.md @@ -341,6 +341,7 @@ steps: config: image: "denoland/deno:1.10.3" autoRemove: true + host: "host.docker.internal" command: run https://examples.deno.land/hello-world.ts ``` @@ -348,29 +349,8 @@ Example Log output: ![docker](./examples/images/docker.png) -You can control the Docker container by passing more detailed options. +To see more configurations, visit [this](https://github.com/yohamta/dagu/tree/main/examples#runing-docker-image) page. -For example: -```yaml -steps: - - name: deno_hello_world - executor: - type: docker - config: - image: "denoland/deno:1.10.3" - container: - volumes: - /app:/app: - env: - - FOO=BAR - host: - autoRemove: true - command: run https://examples.deno.land/hello-world.ts -``` - -See the Docker's API documentation for all available options. -- For `container`, see [ContainerConfig](https://pkg.go.dev/github.com/docker/docker/api/types/container#Config). -- For `host`, see [HostConfig](https://pkg.go.dev/github.com/docker/docker/api/types/container#HostConfig). ### HTTP Requests @@ -814,7 +794,6 @@ dags: # default: ${DAGU_H You can change the status of any task to a `failed` state. Then, when you retry the DAG, it will execute the failed one and any subsequent. ### How does it track running processes without DBMS? - dagu uses Unix sockets to communicate with running processes. ## License diff --git a/examples/README.md b/examples/README.md index 65a0ceb90..98c57bb80 100644 --- a/examples/README.md +++ b/examples/README.md @@ -6,6 +6,8 @@ - [Writing to a file](#writing-to-a-file) - [Passing output to the next step](#passing-output-to-the-next-step) - [Runing Docker image](#runing-docker-image) + - [Container configurations](#container-configurations) + - [How to run docker image inside a `dagu` container](#how-to-run-docker-image-inside-a-dagu-container) - [Runing command via SSH](#runing-command-via-ssh) - [Sending HTTP request](#sending-http-request) - [Sending Email Notification](#sending-email-notification) @@ -103,6 +105,60 @@ steps: command: run https://examples.deno.land/hello-world.ts ``` +### Container configurations + +You can config the Docker container (e.g., `volumes`, `env`, etc) by passing more detailed options. + +For example: +```yaml +steps: + - name: deno_hello_world + executor: + type: docker + config: + image: "denoland/deno:1.10.3" + container: + volumes: + /app:/app: + env: + - FOO=BAR + host: + autoRemove: true + command: run https://examples.deno.land/hello-world.ts +``` + +See the Docker's API documentation for all available options. + +- For `container`, see [ContainerConfig](https://pkg.go.dev/github.com/docker/docker/api/types/container#Config). +- For `host`, see [HostConfig](https://pkg.go.dev/github.com/docker/docker/api/types/container#HostConfig). + +### How to run docker image inside a `dagu` container + +If you are running `dagu` using a container, you need the below setup. + +1. Run a `socat` conainer: + +```sh +docker run -v /var/run/docker.sock:/var/run/docker.sock -p 2376:2375 bobrik/socat TCP4-LISTEN:2375,fork,reuseaddr UNIX-CONNECT:/var/run/docker.sock +``` + +2. Then you can set the `DOCKER_HOST` environment as follows: + +```yaml +env: + - DOCKER_HOST : "tcp://host.docker.internal:2376" +steps: + - name: deno_hello_world + executor: + type: docker + config: + image: "denoland/deno:1.10.3" + autoRemove: true + command: run https://examples.deno.land/hello-world.ts +``` + +For more details, see [this page](https://forums.docker.com/t/remote-api-with-docker-for-mac-beta/15639/2). + ## Runing command via SSH ```yaml diff --git a/examples/exec_docker_image.yaml b/examples/exec_docker_image.yaml index ee4919072..1313cdc84 100644 --- a/examples/exec_docker_image.yaml +++ b/examples/exec_docker_image.yaml @@ -1,3 +1,5 @@ +env: + - DOCKER_HOST : "tcp://host.docker.internal:2376" steps: - name: deno_hello_world executor: