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
`${DOCKERIZED_PROJECT_ROOT}` contains absolute path to the project directory. In this example it is `myproject`.
262
261
263
262
### Adding custom commands
264
263
265
264
Your custom compose file can be called whatever you want. Just make sure it is in the `${COMPOSE_FILE}` variable.
266
265
267
266
Adding a new command to the Compose File:
268
267
```yaml
268
+
# docker-compose.yml
269
269
version: "3"
270
270
services:
271
271
du:
@@ -278,20 +278,52 @@ services:
278
278
You can also mount a directory to the container:
279
279
280
280
```yaml
281
+
# docker-compose.yml
281
282
version: "3"
282
283
services:
283
284
du:
284
285
image: alpine
285
286
entrypoint: ["du"]
286
287
volumes:
287
-
- "${DOCKERIZED_PROJECT_ROOT}/foobar:/foobar"
288
288
- "${HOME}/.config:/root/.config"
289
+
- "${DOCKERIZED_PROJECT_ROOT}/foobar:/foobar"
289
290
```
290
291
> Make sure host volumes are **absolute paths**. For paths relative to home and the project root, you can use `${HOME}` and `${DOCKERIZED_PROJECT_ROOT}`.
291
292
292
293
> 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.
293
294
294
-
> To keep **compatibility** with docker-compose, you can specify a default value for `DOCKERIZED_ROOT` with the following syntax`${DOCKERIZED_PROJECT_ROOT:-someDefaultValue}` instead. For example, `${DOCKERIZED_PROJECT_ROOT:-.}` sets the default to `.`, the compose file directory, allowing you to run your command with docker-compose: `docker-compose --rm du -sh /foobar`.
295
+
> 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`.
296
+
297
+
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`:
298
+
299
+
```yaml
300
+
# docker-compose.yml
301
+
version: "3"
302
+
services:
303
+
aws:
304
+
environment:
305
+
AWS_DEFAULT_REGION: "us-east-1"
306
+
```
307
+
308
+
If you'd like to pass environment variables directly from your `dockerized.env` file, you can expose the variable as follows:
309
+
310
+
```bash
311
+
# dockerized.env
312
+
AWS_DEFAULT_REGION="us-east-1"
313
+
```
314
+
315
+
```yaml
316
+
# docker-compose.yml
317
+
version: "3"
318
+
services:
319
+
aws:
320
+
environment:
321
+
AWS_DEFAULT_REGION: "${AWS_DEFAULT_REGION}"
322
+
```
323
+
324
+
325
+
326
+
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.
0 commit comments