1

I'm trying to create a volume to be shared among the containers, and this volume binds to a location of my host, the problem is that every time I run the docker-compose up gives the following error:

In file '. \ docker-compose.yml', service 'volumes' must be a mapping not an array.

and so far I didn't understand why. Following is the compose file:


version : '3.4'

services:
    testando-volume-compartilhado-a:
      image: carloshenriquecarniatto/teste:latest

    volumes:
       - D:\App:/app
    ports:
        - "10001:80"
        - "44378:443" 
2

It seems there is a spacing issue in your yaml

You should change the compose file to

version : '3.4'

services:
    testando-volume-compartilhado-a:
      image: carloshenriquecarniatto/teste:latest

    volumes:        
        - D:\App:/app  # <- extra space here
    ports:
        - "10001:80"
        - "44378:443" 
  • 1
    The examples in Compose file version 3 reference seem to suggest that the hyphen is actually correct, i.e. it *should be a YAML list. It's possible here that the additional : in the Windows path is confusing the YAML parser? I know little to nothing about Docker Compose. Equally, it might be that the indentation is off, as in the D of volumes is indented by three, ports by four and image by two. – Richard Slater Oct 22 '19 at 16:10
  • you're quite right @RichardSlater – Bruce Becker Oct 22 '19 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.