2015-10-15 22:26:45 -04:00
# Docker Container Options
2015-10-14 05:29:38 -04:00
2023-08-19 14:24:12 -04:00
> [!IMPORTANT]
2015-10-14 05:30:14 -04:00
> New as of 0.3.17
2021-10-06 12:41:35 -04:00
Pass [container options ](https://docs.docker.com/engine/reference/run/ ) to the `docker run` command during Dokku's `build` , `deploy` and `run` phases
2015-11-15 12:18:35 +01:00
2015-11-15 12:22:40 +01:00
```
2016-07-03 17:16:01 -04:00
docker-options:add <app> <phase(s)> OPTION # Add Docker option to app for phase (comma-separated phase list)
2020-02-01 17:06:27 -08:00
docker-options:clear <app> [<phase(s)>...] # Clear a docker options from application
2016-07-03 17:16:01 -04:00
docker-options:remove <app> <phase(s)> OPTION # Remove Docker option from app for phase (comma-separated phase list)
2017-02-20 19:32:59 -07:00
docker-options:report [<app>] [<flag>] # Displays a docker options report for one or more apps
2015-10-14 05:29:38 -04:00
```
2016-01-31 16:27:06 -05:00
> When specifying multiple phases, they **must** be comma-separated _without_ spaces in between each phase, like so:
>
2016-07-03 17:11:23 -04:00
> ```shell
2017-02-20 19:32:59 -07:00
> dokku docker-options:add node-js-app deploy,run "-v /var/log/node-js-app:/app/logs"
2016-01-31 16:27:06 -05:00
> ```
2015-11-15 12:22:40 +01:00
## About Dokku phases
2015-10-14 05:29:38 -04:00
2015-11-15 12:18:35 +01:00
Dokku deploys your application in multiple "phases" and the `docker-options` plugin allows you to pass arguments to their underlying docker container:
- `build` : the container that executes the appropriate buildpack
- `deploy` : the container that executes your running/deployed application
2017-02-20 19:32:59 -07:00
- `run` : the container that executes any arbitrary command via `dokku run`
2015-11-15 12:18:35 +01:00
2020-09-06 13:20:34 -04:00
Manipulation of docker options will not restart running containers. This enables multiple options to be set/unset before final application. As such, changing an app's docker options must be followed by a `dokku ps:rebuild` in order to take effect.
2023-08-19 13:29:12 -04:00
More information on supported Docker options can be found [here ](https://docs.docker.com/engine/reference/commandline/run/ ).
2020-09-06 13:20:34 -04:00
2021-10-06 12:41:35 -04:00
Container options configured via the `docker-options` plugin are not used to modify the process a container runs. Container options are the `[OPTIONS]` portion of the following, where `[CONTAINER_COMMAND]` and `[ARG]` are the process and the arguments passed to it that are launched in the created container: `docker run [OPTIONS] [CONTAINER_COMMAND] [ARG...]` . Please see the documentation for [customizing the run command ](/docs/deployment/builders/dockerfiles.md#customizing-the-run-command ) or use a [Procfile ](/docs/deployment/builders/dockerfiles.md#procfiles-and-multiple-processes ) to modify the command used by a Dockerfile-based container.
2021-10-06 15:04:31 +02:00
2015-11-15 12:18:35 +01:00
## Examples
### Add Docker options
2021-02-28 01:18:33 -05:00
Add some options for the deployed/running app and when executing [`dokku run` ](/docs/processes/one-off-tasks.md ):
2015-11-15 12:18:35 +01:00
```shell
# Mount a host volume in a Docker container: "-v /host/path:/container/path"
2017-02-20 19:32:59 -07:00
dokku docker-options:add node-js-app deploy "-v /var/log/node-js-app:/app/logs"
dokku docker-options:add node-js-app run "-v /var/log/node-js-app:/app/logs"
2015-04-01 12:21:45 -07:00
```
2023-08-19 14:24:12 -04:00
> [!NOTE]
> When [mounting a host directory](https://docs.docker.com/engine/reference/run/#volume-shared-filesystems) in a Dokku app you should first create that directory as user `dokku` and then mount the directory under `/app` in the container using `docker-options` as above. Otherwise the app will lack write permission in the directory.
2015-11-15 12:18:35 +01:00
2017-02-20 19:32:59 -07:00
### Remove a Docker option
```shell
dokku docker-options:remove node-js-app run "-v /var/log/node-js-app:/app/logs"
```
2020-02-01 17:06:27 -08:00
### Clear all Docker options for an app
Docker options can be removed for a specific app using the `docker-options:clear` command.
```shell
dokku docker-options:clear node-js-app
```
```
-----> Clearing docker-options for node-js-app on all phases
```
One or more valid phases can also be specified. Phases are comma delimited, and specifying an invalid phase will result in an error.
```shell
dokku docker-options:clear node-js-app run
```
```
-----> Clearing docker-options for node-js-app on phase run
```
```shell
dokku docker-options:clear node-js-app build,run
```
```
-----> Clearing docker-options for node-js-app on phase build
-----> Clearing docker-options for node-js-app on phase run
```
2019-03-13 16:55:33 -04:00
### Displaying docker-options reports for an app
2017-02-20 19:32:59 -07:00
2023-08-19 14:24:12 -04:00
> [!IMPORTANT]
2017-02-20 19:32:59 -07:00
> New as of 0.8.1
You can get a report about the app's docker-options status using the `docker-options:report` command:
2015-04-01 12:21:45 -07:00
2015-10-14 05:29:38 -04:00
```shell
2017-02-20 19:32:59 -07:00
dokku docker-options:report
2016-07-04 22:59:50 -04:00
```
```
2017-02-20 19:32:59 -07:00
=====> node-js-app docker options information
Docker options build:
Docker options deploy: -v /var/log/node-js-app:/app/logs
Docker options run: -v /var/log/node-js-app:/app/logs
=====> python-sample docker options information
Docker options build:
Docker options deploy:
Docker options run:
=====> ruby-sample docker options information
Docker options build:
Docker options deploy:
Docker options run:
2015-04-01 12:21:45 -07:00
```
2017-02-20 19:32:59 -07:00
You can run the command for a specific app also.
2015-10-14 05:29:38 -04:00
```shell
2017-02-20 19:32:59 -07:00
dokku docker-options:report node-js-app
2015-04-01 12:21:45 -07:00
```
2017-02-20 19:32:59 -07:00
```
=====> node-js-app docker options information
2019-03-13 16:55:11 -04:00
Docker options build:
Docker options deploy: -v /var/log/node-js-app:/app/logs
Docker options run: -v /var/log/node-js-app:/app/logs
2017-02-20 19:32:59 -07:00
```
You can pass flags which will output only the value of the specific information you want. For example:
```shell
dokku docker-options:report node-js-app --docker-options-build
```