mirror of https://github.com/docker/compose.git
Merge pull request #3747 from aanand/clarify-env-docs
Clarify environment, env_file and build.args docs
This commit is contained in:
commit
7f65caa97b
|
@ -115,22 +115,41 @@ specified.
|
||||||
|
|
||||||
> [Version 2 file format](#version-2) only.
|
> [Version 2 file format](#version-2) only.
|
||||||
|
|
||||||
Add build arguments. You can use either an array or a dictionary. Any
|
Add build arguments, which are environment variables accessible only during the
|
||||||
boolean values; true, false, yes, no, need to be enclosed in quotes to ensure
|
build process.
|
||||||
they are not converted to True or False by the YML parser.
|
|
||||||
|
|
||||||
Build arguments with only a key are resolved to their environment value on the
|
First, specify the arguments in your Dockerfile:
|
||||||
machine Compose is running on.
|
|
||||||
|
ARG buildno
|
||||||
|
ARG password
|
||||||
|
|
||||||
|
RUN echo "Build number: $buildno"
|
||||||
|
RUN script-requiring-password.sh "$password"
|
||||||
|
|
||||||
|
Then specify the arguments under the `build` key. You can pass either a mapping
|
||||||
|
or a list:
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
context: .
|
||||||
args:
|
args:
|
||||||
buildno: 1
|
buildno: 1
|
||||||
user: someuser
|
password: secret
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
context: .
|
||||||
args:
|
args:
|
||||||
- buildno=1
|
- buildno=1
|
||||||
- user=someuser
|
- password=secret
|
||||||
|
|
||||||
|
You can omit the value when specifying a build argument, in which case its value
|
||||||
|
at build time is the value in the environment where Compose is running.
|
||||||
|
|
||||||
|
args:
|
||||||
|
- buildno
|
||||||
|
- password
|
||||||
|
|
||||||
|
> **Note**: YAML boolean values (`true`, `false`, `yes`, `no`, `on`, `off`) must
|
||||||
|
> be enclosed in quotes, so that the parser interprets them as strings.
|
||||||
|
|
||||||
### cap_add, cap_drop
|
### cap_add, cap_drop
|
||||||
|
|
||||||
|
@ -276,6 +295,11 @@ beginning with `#` (i.e. comments) are ignored, as are blank lines.
|
||||||
# Set Rails/Rack environment
|
# Set Rails/Rack environment
|
||||||
RACK_ENV=development
|
RACK_ENV=development
|
||||||
|
|
||||||
|
> **Note:** If your service specifies a [build](#build) option, variables
|
||||||
|
> defined in environment files will _not_ be automatically visible during the
|
||||||
|
> build. Use the [args](#args) sub-option of `build` to define build-time
|
||||||
|
> environment variables.
|
||||||
|
|
||||||
### environment
|
### environment
|
||||||
|
|
||||||
Add environment variables. You can use either an array or a dictionary. Any
|
Add environment variables. You can use either an array or a dictionary. Any
|
||||||
|
@ -295,6 +319,11 @@ machine Compose is running on, which can be helpful for secret or host-specific
|
||||||
- SHOW=true
|
- SHOW=true
|
||||||
- SESSION_SECRET
|
- SESSION_SECRET
|
||||||
|
|
||||||
|
> **Note:** If your service specifies a [build](#build) option, variables
|
||||||
|
> defined in `environment` will _not_ be automatically visible during the
|
||||||
|
> build. Use the [args](#args) sub-option of `build` to define build-time
|
||||||
|
> environment variables.
|
||||||
|
|
||||||
### expose
|
### expose
|
||||||
|
|
||||||
Expose ports without publishing them to the host machine - they'll only be
|
Expose ports without publishing them to the host machine - they'll only be
|
||||||
|
|
Loading…
Reference in New Issue