【问题标题】:docker-compose up failing with error service 'version' must be a mapping not a stringdocker-compose up 失败并出现错误 service 'version' must be a mapping not a string
【发布时间】:2020-06-08 19:42:40
【问题描述】:

当我运行 docker-compose up 时出现以下错误。

ERROR: In file '.\docker-compose.yml', service 'version' must be a mapping not a string.

这是我的 docker-compose.yml 文件。

version: "3.0"
services:
  sql:
    image: mcr.microsoft.com/mssql/server:2017-latest-ubuntu
    ports:
      - "5555:1433"
    environment:
      ACCEPT_EULA: "Y"
      MSSQL_PID: "Express"
      SA_PASSWORD: "P@22w0rd"

我使用了下面的文档,不知道我在哪里做错了。 https://docs.docker.com/compose/compose-file/#image

这是我的 docker 引擎客户端/服务器版本:

Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

docker compose 版本

docker-compose version 1.25.5, build 8a1c60f6
docker-py version: 4.1.0
CPython version: 3.7.4
OpenSSL version: OpenSSL 1.1.1c  28 May 2019

操作系统:Windows 10

【问题讨论】:

    标签: docker docker-compose


    【解决方案1】:

    如果你想使用version: "3.8"。确保您have docker version > 19.03.0+。或者您可以尝试使用 version: "3.7" 使用相同的文件,它应该可以解决您的问题

    【讨论】:

    • 我对 3.0 或 2.0 有同样的问题
    【解决方案2】:

    看起来这是某种编码问题。在这里找到相同的https://github.com/docker/compose/issues/5827

    使用 Visual Studio 并将 docker-compose.yml 的内容复制粘贴到新文件中。我最初在创建文件时使用了 Ryder。不知道为什么会导致这个问题。

    【讨论】:

      猜你喜欢
      • 2022-10-25
      • 2022-10-19
      • 2019-12-29
      • 2022-11-16
      • 1970-01-01
      • 2016-10-10
      • 2021-12-13
      • 2012-06-14
      • 1970-01-01
      相关资源
      最近更新 更多