Skip to content

Commit 10ec28a

Browse files
improve documentation
1 parent e1d73e2 commit 10ec28a

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,14 @@ To change settings within a specific directory, create a file `dockerized.env` i
258258
```shell
259259
COMPOSE_FILE="${COMPOSE_FILE};${DOCKERIZED_PROJECT_ROOT}/docker-compose.yml"
260260
```
261-
`${DOCKERIZED_PROJECT_ROOT}` contains absolute path to the project directory. In this example it is `myproject`.
262261

263262
### Adding custom commands
264263

265264
Your custom compose file can be called whatever you want. Just make sure it is in the `${COMPOSE_FILE}` variable.
266265

267266
Adding a new command to the Compose File:
268267
```yaml
268+
# docker-compose.yml
269269
version: "3"
270270
services:
271271
du:
@@ -278,20 +278,52 @@ services:
278278
You can also mount a directory to the container:
279279

280280
```yaml
281+
# docker-compose.yml
281282
version: "3"
282283
services:
283284
du:
284285
image: alpine
285286
entrypoint: ["du"]
286287
volumes:
287-
- "${DOCKERIZED_PROJECT_ROOT}/foobar:/foobar"
288288
- "${HOME}/.config:/root/.config"
289+
- "${DOCKERIZED_PROJECT_ROOT}/foobar:/foobar"
289290
```
290291
> Make sure host volumes are **absolute paths**. For paths relative to home and the project root, you can use `${HOME}` and `${DOCKERIZED_PROJECT_ROOT}`.
291292

292293
> 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.
293294
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.
295327

296328
## Localhost
297329

0 commit comments

Comments
 (0)