Skip to content

Commit 7dfeb9c

Browse files
committed
update docker docs
1 parent d7c1436 commit 7dfeb9c

File tree

1 file changed

+28
-38
lines changed

1 file changed

+28
-38
lines changed

docs/advanced/7_docker/index.mdx

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,36 @@ import DocCard from '@site/src/components/DocCard';
22

33
# Run Docker containers
44

5-
Windmill supports running any [Docker](https://www.docker.com/) container through its [Bash](../../getting_started/0_scripts_quickstart/4_bash_quickstart/index.mdx) support. As a pre-requisite, the host docker daemon needs to be mounted into the worker container. This is done through a simple volume mount: `/var/run/docker.sock:/var/run/docker.sock`.
5+
## Using Windmill native docker support (recommended)
6+
7+
Windmill has a native docker support if the `# docker` annotation is used in a bash script. It will assume a a docker socket is mounted like in the example above and will take over management of the container as soon as the script ends, assuming that the container was ran with the `$WM_JOB_ID` as name.
8+
Which is why you should use docker `-d` deamon mode so that the bash script terminates early.
9+
10+
It will handle memory tracking, logs streaming and the different exit code of the container properly.
11+
12+
The default code is as follows:
13+
14+
```
15+
# docker
16+
# The annotation "docker" above is important, it tells windmill that after
17+
# the end of the bash script, it should manage the container at id $WM_JOB_ID:
18+
# pipe logs, monitor memory usage, kill container if job is cancelled.
19+
20+
msg="${1:-world}"
21+
22+
IMAGE="alpine:latest"
23+
COMMAND="/bin/echo Hello $msg"
624
7-
Once Docker is set up, see:
25+
# ensure that the image is up-to-date
26+
docker pull $IMAGE
827
9-
<div className="grid grid-cols-2 gap-6 mb-4">
10-
<DocCard
11-
title="Docker quickstart"
12-
description="Learn to run a script using from Docker containers."
13-
href="/docs/getting_started/scripts_quickstart/docker"
14-
/>
15-
</div>
28+
# if using the 'docker' mode, name it with $WM_JOB_ID for windmill to monitor it
29+
docker run --name $WM_JOB_ID -it -d $IMAGE $COMMAND
30+
```
1631

17-
## Setup
32+
### Setup
1833

19-
### Docker compose
34+
#### Docker compose
2035

2136
On the docker-compose, it is enough to uncomment the volume mount of the Windmill worker
2237

@@ -25,7 +40,7 @@ On the docker-compose, it is enough to uncomment the volume mount of the Windmil
2540
# - /var/run/docker.sock:/var/run/docker.sock
2641
```
2742

28-
### Helm charts
43+
#### Helm charts
2944

3045
In the charts values of our [helm charts](https://github.com/windmill-labs/windmill-helm-charts), set `windmill.exposeHostDocker` to `true`.
3146

@@ -77,35 +92,10 @@ Here an example of a a worker group setup with a dind side-container to be adapt
7792
name: sock-dir
7893
```
7994

80-
## Using Windmill native docker support (recommended)
8195

82-
Windmill has a native docker support if the `# docker` annotation is used. It will assume a a docker socket is mounted like in the example above and will take over management of the container as soon as the script ends, assuming that the container was ran with the `$WM_JOB_ID` as name.
83-
Which is why you should use docker `-d` deamon mode so that the bash script terminates early.
84-
85-
It will handle memory tracking, logs streaming and the different exit code of the container properly.
86-
87-
The default code is as follows:
88-
89-
```
90-
# docker
91-
# The annotation "docker" above is important, it tells windmill that after
92-
# the end of the bash script, it should manage the container at id $WM_JOB_ID:
93-
# pipe logs, monitor memory usage, kill container if job is cancelled.
94-
95-
msg="${1:-world}"
96-
97-
IMAGE="alpine:latest"
98-
COMMAND="/bin/echo Hello $msg"
99-
100-
# ensure that the image is up-to-date
101-
docker pull $IMAGE
102-
103-
# if using the 'docker' mode, name it with $WM_JOB_ID for windmill to monitor it
104-
docker run --name $WM_JOB_ID -it -d $IMAGE $COMMAND
105-
```
10696

10797

108-
## Using remote container runtimes (not recommended)
98+
### Using remote container runtimes (not recommended)
10999

110100
This method is not recommended because it skips Windmill's native docker runtime and simpl execute as a normal bash script.
111101

0 commit comments

Comments
 (0)