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

update examples for docker container #365

Merged
merged 1 commit into from
Nov 20, 2022
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
25 changes: 2 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,36 +341,16 @@ steps:
config:
image: "denoland/deno:1.10.3"
autoRemove: true
host: "host.docker.internal"
command: run https://examples.deno.land/hello-world.ts
```

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

Expand Down Expand Up @@ -814,7 +794,6 @@ dags: <the location of DAG configuration files> # 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
Expand Down
56 changes: 56 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/exec_docker_image.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
env:
- DOCKER_HOST : "tcp://host.docker.internal:2376"
steps:
- name: deno_hello_world
executor:
Expand Down