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: README.md
+116-8Lines changed: 116 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,7 @@
1
-
# Dockerized [](https://github.com/datastack-net/dockerized/actions/workflows/test.yml)
1
+

2
+
3
+
# Dockerized [](https://github.com/datastack-net/dockerized/actions/workflows/test.yml)
4
+
2
5
Run popular commandline tools without installing them.
3
6
4
7
```shell
@@ -9,7 +12,7 @@ dockerized <command>
9
12
10
13
## Supported commands
11
14
12
-
> If your favorite command is not included, it can be added very easily. See [Add a command](DEV.md).
15
+
> If your favorite command is not included, it can be added very easily. See [Customization](#customization).
13
16
> Dockerized will also fall back to over 150 commands defined in [jessfraz/dockerfiles](https://github.com/jessfraz/dockerfiles).
Add `:<version>` to the end of the command to override the version.
160
163
@@ -163,7 +166,7 @@ dockerized node:15
163
166
```
164
167
165
168
166
-
**Listing versions**
169
+
### Listing versions
167
170
168
171
To see which versions are available, run:
169
172
@@ -173,7 +176,7 @@ dockerized node:?
173
176
dockerized node:
174
177
```
175
178
176
-
**Environment Variables**
179
+
### Environment Variables
177
180
178
181
Each command has a `<COMMAND>_VERSION` environment variable which you can override.
179
182
@@ -203,12 +206,12 @@ Notes:
203
206
- [.env](.env)
204
207
205
208
206
-
**Per directory**
209
+
**Per project (directory)**
207
210
208
-
You can also specify version and other settings per directory.
211
+
You can also specify version and other settings per directory and its subdirectory.
209
212
This allows you to "lock" your tools to specific versions for your project.
210
213
211
-
- Create a `dockerized.env` file in your project directory.
214
+
- Create a `dockerized.env` file inthe root of your project directory.
212
215
- All commands executed within this directory will use the settings specified in this file.
213
216
214
217
@@ -229,6 +232,111 @@ This allows you to "lock" your tools to specific versions for your project.
229
232
dockerized node
230
233
```
231
234
235
+
## Customization
236
+
237
+
Dockerized uses [Docker Compose](https://docs.docker.com/compose/overview/) to run commands, which are defined in a Compose File.
238
+
The default commands are listed in [docker-compose.yml](docker-compose.yml). You can add your own commands or customize the defaults, by loading a custom Compose File.
239
+
240
+
The `COMPOSE_FILE` environment variable defines which files to load. This variable is set by the included [.env](.env) file, and your own `dockerized.env` files, as explained in [Environment Variables](#environment-variables). To load an additional Compose File, add the path to the file to the `COMPOSE_FILE` environment variable.
241
+
242
+
243
+
### Including an additional Compose File
244
+
245
+
**Globally**
246
+
247
+
To change global settings, create a file `dockerized.env`in your home directory, which loads an extra Compose File.
248
+
In this example, the Compose File is also in the home directory, referenced relative to the `${HOME}` directory. The original variable `${COMPOSE_FILE}` is included to preserve the default commands. Omit it if you want to completely replace the default commands.
To change settings within a specific directory, create a file `dockerized.env`in the root of that directory, which loads the extra Compose File. `${DOCKERIZED_PROJECT_ROOT}` refers to the absolute path to the root of the project.
After adding your custom Compose File to `COMPOSE_FILE`, you can add your own commands.
275
+
276
+
```yaml
277
+
# docker-compose.yml
278
+
version: "3"
279
+
services:
280
+
du:
281
+
image: alpine
282
+
entrypoint: ["du"]
283
+
```
284
+
285
+
> Now you can run `dockerized du` to see the size of the current directory.
286
+
287
+
> To learn how to support versioning, see [Development Guide: Configurable Version](DEV.md#configurable-version).
288
+
289
+
You can also mount a directory to the container:
290
+
291
+
```yaml
292
+
# docker-compose.yml
293
+
version: "3"
294
+
services:
295
+
du:
296
+
image: alpine
297
+
entrypoint: ["du"]
298
+
volumes:
299
+
- "${HOME}/.config:/root/.config"
300
+
- "${DOCKERIZED_PROJECT_ROOT}/foobar:/foobar"
301
+
```
302
+
303
+
> Make sure host volumes are **absolute paths**. For paths relative to home and the project root, you can use `${HOME}` and `${DOCKERIZED_PROJECT_ROOT}`.
304
+
305
+
> It is possible to use **relative paths**in the service definitions, but then your Compose File must be loaded **before** the default: `COMPOSE_FILE=${DOCKERIZED_PROJECT_ROOT}/docker-compose.yml;${COMPOSE_FILE}`. All paths are relative to the first Compose File. Compose Files are also merged in the order they are specified, with the last Compose File overriding earlier ones. Because of this, if you want to override the default Compose File, you must load it before _your_ file, and you can't use relative paths.
306
+
307
+
> To keep **compatibility** with docker-compose, you can specify a default value for `DOCKERIZED_PROJECT_ROOT`, for example: `${DOCKERIZED_PROJECT_ROOT:-.}` sets the default to `.`, allowing you to run like this as well: `docker-compose --rm du -sh /foobar`.
308
+
309
+
To customize existing commands, you can override or add properties to the `services` section of the Compose File, for the command you want to customize. For example, this is how to set an extra environment variable for `dockerized aws`:
310
+
311
+
```yaml
312
+
# docker-compose.yml
313
+
version: "3"
314
+
services:
315
+
aws:
316
+
environment:
317
+
AWS_DEFAULT_REGION: "us-east-1"
318
+
```
319
+
320
+
If you'd like to pass environment variables directly from your `dockerized.env` file, you can expose the variable as follows:
321
+
322
+
```bash
323
+
# dockerized.env
324
+
AWS_DEFAULT_REGION="us-east-1"
325
+
```
326
+
327
+
```yaml
328
+
# docker-compose.yml
329
+
version: "3"
330
+
services:
331
+
aws:
332
+
environment:
333
+
AWS_DEFAULT_REGION: "${AWS_DEFAULT_REGION}"
334
+
```
335
+
336
+
337
+
338
+
For more information on extending Compose Files, see the Docker Compose documentation: [Multiple Compose Files](https://docs.docker.com/compose/extends/#multiple-compose-files). Note that the `extends` keyword is not supported in the Docker Compose version used by Dockerized.
339
+
232
340
## Localhost
233
341
234
342
Dockerized applications run within an isolated network. To access services running on your machine, you need to use `host.docker.internal` instead of `localhost`.
0 commit comments