Invalid type in docker-compose volume

Nicolas picture Nicolas · Apr 26, 2017 · Viewed 13.3k times · Source

I try to setup a bind volume in my docker-compose but I get the following error:

docker-compose up
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.web.volumes contains an invalid type, it should be a string

My docker-compose file:

version: '3'
services:
  web:
    #build: .
    image: fnndsc/fnndsc.babymri.org
    ports:
      - "8060:8080"
    volumes:
      - type: "bind"
        source: "."
        target: "/src/website"
    labels:
      name: "FNNDSC Web App"
      role: "FNNDSC Web App development server"

Versions:

Docker version 17.03.1-ce, build c6d412e

docker-compose version 1.12.0, build b31ff33

I tried many different combinations but nothing seems to work...

Thanks!

Answer

Nicolas picture Nicolas · Apr 27, 2017

Version 3.2 is required for the extended notation:

version: '3.2'
services:
  web:
    #build: .
    image: fnndsc/fnndsc.babymri.org
    ports:
      - "8060:8080"
    volumes:
      - type: bind
        source: .
        target: /src/website
    labels:
      name: "FNNDSC Web App"
      role: "FNNDSC Web App development server"

Reference: https://github.com/docker/compose/issues/4763#issuecomment-297509279