Answers: <p>It seems there is a spacing issue in your yaml</p>
  
  <p>You should change the compose file to</p>
  
  <pre><code>version : '3.4'
  
  services:
      testando-volume-compartilhado-a:
        image: carloshenriquecarniatto/teste:latest
  
      volumes:        
          - D:\App:/app  # &lt;- extra space here
      ports:
          - "10001:80"
          - "44378:443" 
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-10-22T16:10:56.813Z
Answers: The examples in [Compose file version 3 reference](https://docs.docker.com/compose/compose-file/) 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](https://stackoverflow.com/questions/39555650/error-in-file-docker-compose-yml-service-volumes-must-be-a-mapping-not-a), as in the D of volumes is indented by three, ports by four and image by two.
Answers: Richard Slater
Answers: CC BY-SA 4.0
Answers: 2019-10-22T16:31:58.827Z
Answers: you're quite right @RichardSlater
Answers: Bruce Becker
Answers: CC BY-SA 4.0
Answers: 2019-10-22T13:18:24.563Z
Answers: 2019-10-22T16:55:28.810Z
Answers: 2019-10-22T16:55:28.810Z
Answers: Bruce Becker
Answers: <p>It is a spacing issue, but because of indentation.</p>
  <p><code>volumes</code> and <code>ports</code> should be at the same level of image</p>
  <pre><code>version : '3.4'
  </code></pre>
  <p>services:
  testando-volume-compartilhado-a:
  image: carloshenriquecarniatto/teste:latest</p>
  <pre><code>  volumes:
       - D:\App:/app
    ports:
        - &quot;10001:80&quot;
        - &quot;44378:443&quot; 
  </code></pre>
  <p>I am not sure about the Windows volume mapping (Linux only here)...but the indentation was off for sure!</p>
  
Answers: CC BY-SA 4.0
Answers: 2023-12-17T23:34:08.723Z
Answers: 2023-12-17T23:34:08.723Z
Answers: Luigi Palumbo
Body: <p>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: </p>
  
  <pre><code>In file '. \ docker-compose.yml', service 'volumes' must be a mapping not an array.
  </code></pre>
  
  <p>and so far I didn't understand why.  Following is the compose file:</p>
  
  <pre><code>
  version : '3.4'
  
  services:
      testando-volume-compartilhado-a:
        image: carloshenriquecarniatto/teste:latest
  
      volumes:
         - D:\App:/app
      ports:
          - "10001:80"
          - "44378:443" 
  </code></pre>
  
Comments: CC BY-SA 4.0
Comments: 2019-10-22T13:24:00.997Z
Comments: I have maked changes but not solved....
Comments: Carlos Henrique Carniatto
Tags: <docker><windows><volume>
Title: Why does my Docker composer not work with volume?
UserDisplayName: Carlos Henrique Carniatto
ThreadText: # Why does my Docker composer not work with volume?
  
  (Asked by: username_0 on 2019-10-22)
  
  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: username_0/teste:latest
  
      volumes:
         - D:\App:/app
      ports:
          - "10001:80"
          - "44378:443" 
  
  ```
  
  **Tags:** docker, windows, volume
  
  > **Comments:**
  > **username_0**: I have maked changes but not solved....  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-10-22. Score: 4
  
  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: username_0/teste:latest
  
      volumes:        
          - D:\App:/app  # <- extra space here
      ports:
          - "10001:80"
          - "44378:443" 
  
  ```
  
  > **Comments:**
  > **username_2**: The examples in [Compose file version 3 reference](https://docs.docker.com/compose/compose-file/) 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](https://stackoverflow.com/questions/39555650/error-in-file-docker-compose-yml-service-volumes-must-be-a-mapping-not-a), as in the D of volumes is indented by three, ports by four and image by two.  
  > **username_1**: you're quite right @username_2  
  
  ---
  
  ### Answer by username_3 on 2023-12-17. Score: 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: username_0/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!
  
  
  ---
  
  