Search code examples
dockerdocker-compose

docker-compose up failing with error service 'version' must be a mapping not a string


when I run docker-compose up I'm getting the error below.

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

here is my docker-compose.yml file.

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"

I used the documentation below, not sure where I'm doing wrong. https://docs.docker.com/compose/compose-file/#image

Here is my docker engine client/server versions:

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 version

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

OS: Windows 10


Solution

  • Looks like it was some kind of encoding issue. Found the same here https://github.com/docker/compose/issues/5827

    Using visual studio and copy pasting the content of docker-compose.yml to the new file worked. I used Ryder originally when creating the file. Not sure why it caused this issue though.