Several environment variables are available for you to configure the Docker Compose command-line behaviour.

可以使用几个环境变量来配置Docker Compose命令行行为。

COMPOSE_PROJECT_NAME

Sets the project name. This value is prepended along with the service name to the container on start up. For example, if your project name is myapp and it includes two services db and web, then Compose starts containers named myapp_db_1 and myapp_web_1 respectively.

设置项目名称。 启动时,此值与服务名称一起添加到容器中。 例如,如果您的项目名称为myapp并且包含两个服务db和web,则Compose分别启动名为myapp_db_1和myapp_web_1的容器。

Setting this is optional. If you do not set this, the COMPOSE_PROJECT_NAME defaults to the basename of the project directory. See also the -p command-line option.

设置为可选。 如果未设置此项,则COMPOSE_PROJECT_NAME默认为项目目录的基本名称。 另请参见-p命令行选项。

COMPOSE_FILE

Specify the path to a Compose file. If not provided, Compose looks for a file nameddocker-compose.yml in the current directory and then each parent directory in succession until a file by that name is found.

指定一个Compose文件的路径。 如果未提供,则Compose在当前目录中查找名为docker-compose.yml的文件,然后依次查找每个父目录,直到找到具有该名称的文件。

This variable supports multiple Compose files separated by a path separator (on Linux and macOS the path separator is :, on Windows it is ;). For example:COMPOSE_FILE=docker-compose.yml:docker-compose.prod.yml. The path separator can also be customized using COMPOSE_PATH_SEPARATOR.

此变量支持由路径分隔符分隔的多个Compose文件(在Linux和macOS上,路径分隔符为:,在Windows上为;)。

例如COMPOSE_FILE=docker-compose.yml:docker-compose.prod.yml

路径分隔符也可以使用COMPOSE_PATH_SEPARATOR进行自定义。

See also the -f command-line option.

COMPOSE_API_VERSION

The Docker API only supports requests from clients which report a specific version. If you receive a client and server don't have same version error using docker-compose, you can workaround this error by setting this environment variable. Set the version value to match the server version.

Docker API仅支持来自报告特定版本的客户端的请求。 如果你在使用docker-compose时,接收到一个 客户端和服务器没有相同的版本的错误,则可以通过设置此环境变量来解决此错误。 设置版本值以匹配服务器版本。

Setting this variable is intended as a workaround for situations where you need to run temporarily with a mismatch between the client and server version. For example, if you can upgrade the client but need to wait to upgrade the server.

设置此变量的目的是为了解决需要临时运行而客户端和服务器版本不匹配的情况。 例如,如果您可以升级客户端,但是需要等待服务器升级。

Running with this variable set and a known mismatch does prevent some Docker features from working properly. The exact features that fail would depend on the Docker client and server versions. For this reason, running with this variable set is only intended as a workaround and it is not officially supported.

运行时使用此变量设置并在已知不匹配的情况下,确实会阻止某些Docker功能正常运行。 失败的确切功能取决于Docker客户端和服务器版本。 因此,运行时使用此变量设置仅是一种变通办法,并且不受官方支持。

If you run into problems running with this set, resolve the mismatch through upgrade and remove this setting to see if your problems resolve before notifying support.

如果在使用此设置运行时遇到问题,请通过升级解决不匹配问题,并在通知支持人员前,删除此设置查看问题是否解决。

DOCKER_HOST

Sets the URL of the docker daemon. As with the Docker client, defaults to 

unix:///var/run/docker.sock.

DOCKER_TLS_VERIFY

When set to anything other than an empty string, enables TLS communication with the docker daemon.

设置为空字符串以外的其他任何值时,启用与docker守护程序的TLS通信。

DOCKER_CERT_PATH

Configures the path to the ca.pemcert.pem, and key.pem files used for TLS verification. Defaults to ~/.docker.

COMPOSE_HTTP_TIMEOUT

Configures the time (in seconds) a request to the Docker daemon is allowed to hang before Compose considers it failed. Defaults to 60 seconds.

COMPOSE_TLS_VERSION

Configure which TLS version is used for TLS communication with the docker daemon. Defaults to TLSv1. Supported values are: TLSv1TLSv1_1TLSv1_2.

COMPOSE_CONVERT_WINDOWS_PATHS

Enable path conversion from Windows-style to Unix-style in volume definitions. Users of Docker Machine and Docker Toolbox on Windows should always set this. Defaults to 0. Supported values: true or 1 to enable, false or 0 to disable.

在卷定义中启用从Windows样式到Unix样式的路径转换。 Windows上的Docker Machine和Docker Toolbox的用户应始终对此进行设置。 默认值为0.支持的值:true或1启用,false或0禁用。

COMPOSE_PATH_SEPARATOR

If set, the value of the COMPOSE_FILE environment variable is separated using this character as path separator.

如果已设置,则使用此字符作为路径分隔符分隔COMPOSE_FILE环境变量的值。

COMPOSE_FORCE_WINDOWS_HOST

If set, volume declarations using the short syntax are parsed assuming the host path is a Windows path, even if Compose is running on a UNIX-based system. Supported values: true or 1 to enable, false or 0 to disable.

如果已设置,即使Compose在基于UNIX的系统上运行,也会假设主机路径是Windows路径,但会使用短语法解析卷声明。支持的值:true或1启用,false或0禁用。

COMPOSE_IGNORE_ORPHANS

If set, Compose doesn’t try to detect orphaned containers for the project. Supported values: true or 1 to enable, false or 0 to disable.

如果已设置,则Compose不会尝试检测项目的孤立容器。支持的值:true或1启用,false或0禁用。

COMPOSE_PARALLEL_LIMIT

Sets a limit for the number of operations Compose can execute in parallel. The default value is 64, and may not be set lower than 2.

设置Compose可以并行执行的操作数的限制。 默认值为64,并且不得设置为小于2。

COMPOSE_INTERACTIVE_NO_CLI

If set, Compose doesn’t attempt to use the Docker CLI for interactive run and exec operations. This option is not available on Windows where the CLI is required for the aforementioned operations. Supported: true or 1 to enable, false or 0 to disable.

如果已设置,则Compose不会尝试使用Docker CLI进行交互式运行和执行操作。 在上述操作需要CLI的Windows上,此选项不可用。支持的值:true或1启用,false或0禁用。