You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced/7_docker/index.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,9 +80,9 @@ Here an example of a a worker group setup with a dind side-container to be adapt
80
80
## Using Windmill native docker support (recommended)
81
81
82
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.
83
+
Which is why you should use docker `-d` deamon mode so that the bash script terminates early.
84
84
85
-
It will handle memory tracking, logs streaming and the different exit code of the container properly.
85
+
It will handle memory tracking, logs streaming and the different exit code of the container properly.
# if using the 'docker' mode, name it with $WM_JOB_ID for windmill to monitor it
71
+
docker run --name $WM_JOB_ID -it -d $IMAGE$COMMAND
137
72
```
138
73
139
-
## Setup
140
-
141
-
To set-up Docker, see:
142
-
143
-
<div className="grid grid-cols-2 gap-6 mb-4">
144
-
<DocCard
145
-
title="Docker Set-Up"
146
-
description="Windmill supports running any Docker container through its Bash support."
147
-
href="/docs/advanced/docker"
148
-
/>
149
-
</div>
150
-
151
-
## Use
74
+
To see more details about to setup your kubernetes or docker-compose setup to run docker containers, see [Run docker containers](../../../advanced/7_docker/index.mdx)
152
75
153
-
From the Home page of Windmill App, click `+Script`. This will take you to the
154
-
first step of script creation: Metadata.
155
76
156
77
## Settings
157
78
@@ -209,35 +130,31 @@ boilerplate. Let's take a look:
209
130
210
131
```bash
211
132
# shellcheck shell=bash
212
-
# Bash script that calls docker as a client to the host daemon
213
-
# See documentation: https://www.windmill.dev/docs/advanced/docker
133
+
# docker
134
+
# The annotation "docker" above is important, it tells windmill that after
135
+
# the end of the bash script, it should manage the container at id $WM_JOB_ID:
136
+
# pipe logs, monitor memory usage, kill container if job is cancelled.
137
+
214
138
msg="${1:-world}"
215
139
216
140
IMAGE="alpine:latest"
217
141
COMMAND="/bin/echo Hello $msg"
218
142
219
143
# ensure that the image is up-to-date
220
144
docker pull $IMAGE
221
-
docker run --rm $IMAGE $COMMAND
145
+
146
+
# if using the 'docker' mode, name it with $WM_JOB_ID for windmill to monitor it
147
+
docker run --name $WM_JOB_ID -it -d $IMAGE$COMMAND
222
148
```
223
149
224
150
`msg` is just a normal Bash variable. It can be used to pass arguments to the script. This syntax is the standard Bash one to assign default values to parameters.
225
151
226
152
```
227
-
docker run --rm <image> <command>
153
+
docker run --name $WM_JOB_ID -it -d $IMAGE $COMMAND
228
154
```
229
155
230
-
--rm is so that the container dispose itself after being executed. It helps unpollute the host.
231
-
232
-
The image is the docker image to run. It can be any image available on docker hub or any private registry. It can also be a local image.
233
-
234
-
The command is the command to run inside the container. It can be any command available in the image.
235
-
236
-
It is just a Bash script so it will behave exactly the same as a local command or if running this as an ssh command on the host. As a consequence, you can use any strategy to cache docker images or handle authentication.
237
-
238
-
Do not use the daemon mode `-d` otherwise the script will immediately return while the container continue to run in the background. However, in some cases, that might be what you want.
239
-
240
-
Like any Bash script, it will return the last line of the stdout. So be sure to print the return value from your command if you'd like to use it as a result.
156
+
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.
157
+
Which is why you should use docker `-d` deamon mode so that the bash script terminates early.
0 commit comments