Skip to main content
 首页 » 编程设计

docker-compose:客户端版本太新

2024年11月01日34hnrainll

当执行 DOCKER_API_VERSION=1.35 docker-compose --verbose up 我得到:

-d compose.config.config.find: Using configuration files: ./docker-compose.yml docker.utils.config.find_config_file: Trying paths: ['/home/vivo/.docker/config.json', '/home/vivo/.dockercfg'] docker.utils.config.find_config_file: No config file found docker.utils.config.find_config_file: Trying paths: ['/home/vivo/.docker/config.json', '/home/vivo/.dockercfg'] docker.utils.config.find_config_file: No config file found urllib3.connectionpool._make_request: http://localhost:None "GET /v2.25/version HTTP/1.1" 400 84 Traceback (most recent call last):
File "site-packages/docker/api/client.py", line 261, in _raise_for_status File "site-packages/requests/models.py", line 940, in raise_for_status requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http+docker://localhost/v2.25/version

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "bin/docker-compose", line 6, in File "compose/cli/main.py", line 71, in main File j

"compose/cli/main.py", line 124, in perform_command File "compose/cli/command.py", line 42, in project_from_options File "compose/cli/command.py", line 123, in get_project File "compose/cli/command.py", line 97, in get_client File "site-packages/docker/api/daemon.py", line 181, in version File "site-packages/docker/api/client.py", line 267, in _result File "site-packages/docker/api/client.py", line 263, in _raise_for_status
File "site-packages/docker/errors.py", line 31, in create_api_error_from_http_exception docker.errors.APIError: 400 Client Error: Bad Request ("client version 2.25 is too new. Maximum supported API version is 1.38")

我的 docker 版本:

docker-tutorial % docker version Client: Version:
18.06.3-ce API version: 1.27 Go version: go1.10.3 Git commit: d7080c1 Built: Wed Feb 20 02:27:13 2019 OS/Arch: linux/amd64 Experimental: false

Server: Engine: Version: 18.06.3-ce API version:
1.38 (minimum version 1.12) Go version: go1.10.3 Git commit: d7080c1 Built: Wed Feb 20 02:25:38 2019 OS/Arch:
linux/amd64 Experimental: false

我的 docker-compose 版本:

docker-tutorial % docker-compose version docker-compose version 1.24.1, build 4667896b docker-py version: 3.7.3 CPython version: 3.6.8 OpenSSL version: OpenSSL 1.1.0j 20 Nov 2018

还有我的 docker-compose.yml:

version: '2.3' 
 
services: 
    app: 
        image: php:7.2-apache 
        volumes: 
            - .:/var/www/html 
        ports: 
            - 8000:80 

请您参考如下方法:

请引用here
问题似乎已在 Docker 版本 18.09 及更高版本中得到修复。值得升级。如果您不希望容器在 Docker 版本升级时受到影响,请在 daemon.json 上启用 live-restore 并执行 systemctl reload daemon。之后执行升级。