Docker Compose でボリュームをマウントする際、type: を用いたときに "services.postgresql.volumes contains an invalid type, it should be a string" と怒られてしまう場合への対処法

状況

docker-compose.ymlvolumes: が以下のように書かれていたとします。

    volumes:
      - type: bind
        source: ./foo
        target: /var/lib/bar

その上で、$ docker-compose up を実行した際に以下のようなエラーが出る場合を考えます。

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

結論

docker-compose.ymlversion:3.2 以上に指定する*1

version: "3.2"

(中略)
    volumes:
      - type: bind
        source: ./foo
        target: /var/lib/bar
(後略)

参考

github.com

*1:この数値はクォートする必要があります

Powered by はてなブログ