Why does my Docker composer not work with volume?

12,978

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" 
Share:
12,978

Related videos on Youtube

rpetrich
Author by

rpetrich

Websites: Company: www.AbitMORE-SCM.com SCM: Dr.Chgman.com Drupal: Drupal.PlaceTo.Be eMail: Pierre.Vriens at www.AbitMORE-SCM.com     Moderation (6/8): Civic Duty Cleanup Deputy Electorate Marshal Sportsmanship Reviewer Steward Editing (5/6): Organizer Copy Editor Explainer Refiner Tag Editor Strunk &amp; White Participation (5/6): Constituent Convention Enthusiast Investor Quorum Yearling

Updated on September 18, 2022

Comments

  • rpetrich
    rpetrich almost 2 years

    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" 
    
    • Admin
      Admin over 4 years
      I have maked changes but not solved....
  • Richard Slater
    Richard Slater over 4 years
    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.
  • Bruce Becker
    Bruce Becker over 4 years
    you're quite right @RichardSlater