Skip to content

Commit

Permalink
update examples for docker container (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
yottahmd authored Nov 20, 2022
1 parent 03c08b8 commit f156fc9
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 23 deletions.
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

0 comments on commit f156fc9

Please sign in to comment.