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

CC BY-SA 4.0
2019-10-22T16:10:56.813Z
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.
Richard Slater
CC BY-SA 4.0
2019-10-22T16:31:58.827Z
you're quite right @RichardSlater
Bruce Becker
CC BY-SA 4.0
2019-10-22T13:18:24.563Z
2019-10-22T16:55:28.810Z
2019-10-22T16:55:28.810Z
Bruce Becker
<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>

CC BY-SA 4.0
2023-12-17T23:34:08.723Z
2023-12-17T23:34:08.723Z
Luigi Palumbo
<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>

CC BY-SA 4.0
2019-10-22T13:24:00.997Z
I have maked changes but not solved....
Carlos Henrique Carniatto
<docker><windows><volume>
Why does my Docker composer not work with volume?
Carlos Henrique Carniatto
# 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: carloshenriquecarniatto/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: carloshenriquecarniatto/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 @RichardSlater  

---

### 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: 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!


---

