HiveBrain v1.2.0
Get Started
← Back to all entries
gotchadockerMinor

Why does my Docker composer not work with volume?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
whycomposerdockerwithworkdoesnotvolume

Problem

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"

Solution

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"

Code Snippets

version : '3.4'

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

    volumes:        
        - D:\App:/app  # <- extra space here
    ports:
        - "10001:80"
        - "44378:443"

Context

StackExchange DevOps Q#9522, answer score: 3

Revisions (0)

No revisions yet.