如何用 docker-COMPOSE 命令覆盖 COMPOSE_HTTP_TIMEOUT 的默认值

我有码头构图,其中获取一些图像,并建立一个。 当我运行 docker-compose up时,会得到以下错误

错误: HTTP 请求花了太长时间才完成 以获取调试信息。如果您经常遇到这个问题 由于网络条件缓慢,请考虑设置 COMPOSE _ HTTP _ TIMEOUT 设置为更高的值(当前值: 60)。

问题: 如何使用 docker-compose命令传递 COMPOSE_HTTP_TIMEOUT

100395 次浏览

COMPOSE_HTTP_TIMEOUT is an environment variable, so

COMPOSE_HTTP_TIMEOUT=200 docker-compose up

You need your COMPOSE_HTTP_TIMEOUT at your docker instance level (docker-compose up) and not inside your docker image. So the solution is to create a .env file and put this inside:

#.env
COMPOSE_HTTP_TIMEOUT=200

you can check the doc here

I faced this issue recently. Even after overriding the default COMPOSE_HTTP_TIMEOUT value it did not work for me.

Possible cause As mentioned in documentation Compose CLI environment variables

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.

Removing the tty:true from my docker-compose worked for me.

More details on the issueCompose error "HTTP request took too long to complete" #3633

Docker Environment details:

$ docker-compose version


docker-compose version 1.18.0, build 8dd22a9
docker-py version: 2.6.1
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t  3 May 2016






$ docker version
Client:
Version:           18.09.1
API version:       1.39
Go version:        go1.10.6
Git commit:        4c52b90
Built:             Wed Jan  9 19:35:01 2019
OS/Arch:           linux/amd64
Experimental:      false


Server: Docker Engine - Community
Engine:
Version:          18.09.1
API version:      1.39 (minimum version 1.12)
Go version:       go1.10.6
Git commit:       4c52b90
Built:            Wed Jan  9 19:06:30 2019
OS/Arch:          linux/amd64
Experimental:     false

restart the docker

command: sudo service docker restart

then try docker-compose up

For Mac users, restarting docker from the status bar icon fixed this issue:

Restarting Docker

Add this one in .env file: COMPOSE_HTTP_TIMEOUT=1000

Open terminal and type following command

COMPOSE_HTTP_TIMEOUT=200

To verify type

echo $COMPOSE_HTTP_TIMEOUT

Output: 200