2

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" 
1

2 Answers 2

3

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" 
2
  • 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. Oct 22, 2019 at 16:10
  • you're quite right @RichardSlater Oct 22, 2019 at 16:31
0

It is a spacing issue, but because of indentation.

volumes and ports should be at the same level of image

version : '3.4'

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

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

I am not sure about the Windows volume mapping (Linux only here)...but the indentation was off for sure!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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