Answers: <p>You need to specify the container name (which is a variable, called CONTAINER_NAME here), you might want to call it postgres_server or something like that:</p>
  <pre><code>version: &quot;3.7&quot;
  services:
    CONTAINER_NAME:
     image:  postgres
     environment:
       - POSTGRES_DB=postgres
       - POSTGRES_USER=postgres
       - POSTGRES_PASSWORD=postgres
  
     build: .
     command: python manage.py runserver 0.0.0.0:8000
     volumes:
       - .:/app
     ports:
       - &quot;8000:8000&quot;
     depends_on:
       - db
  </code></pre>
  <p>source :
  <a href="https://stackoverflow.com/questions/56733841/service-image-must-be-a-mapping-not-a-string">https://stackoverflow.com/questions/56733841/service-image-must-be-a-mapping-not-a-string</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2022-07-12T08:55:58.127Z
Answers: 2023-04-08T11:54:00.770Z
Answers: 2023-04-08T11:54:00.770Z
Answers: tintin
Body: <p>My volume isn't being created with the containers, this volume binds with the host, every time I try to attempt to run it or go to an online validator for yaml, it shows the correct validation on the validator but fails to run:</p>
  <blockquote>
  <p>ERROR: In file './docker-compose.yaml', service 'image' must be a mapping not a string.</p>
  </blockquote>
  <p>and I can't understand what's causing this when the online validator says it's a valid yaml.</p>
  <pre><code>version: &quot;3.7&quot;
  services:
   image:  postgres
   environment:
     - POSTGRES_DB=postgres
     - POSTGRES_USER=postgres
     - POSTGRES_PASSWORD=postgres
  
   build: .
   command: python manage.py runserver 0.0.0.0:8000
   volumes:
     - .:/app
   ports:
     - &quot;8000:8000&quot;
   depends_on:
     - db
  </code></pre>
  
Tags: <docker-compose>
Title: Why is my docker composer volume not working?
UserDisplayName: user36023
ThreadText: # Why is my docker composer volume not working?
  
  (Asked by: username_0 on 2022-07-11)
  
  My volume isn't being created with the containers, this volume binds with the host, every time I try to attempt to run it or go to an online validator for yaml, it shows the correct validation on the validator but fails to run:
  
  > ERROR: In file './docker-compose.yaml', service 'image' must be a mapping not a string.
  
  and I can't understand what's causing this when the online validator says it's a valid yaml.
  
  ```
  version: "3.7"
  services:
   image:  postgres
   environment:
     - POSTGRES_DB=postgres
     - POSTGRES_USER=postgres
     - POSTGRES_PASSWORD=postgres
  
   build: .
   command: python manage.py runserver 0.0.0.0:8000
   volumes:
     - .:/app
   ports:
     - "8000:8000"
   depends_on:
     - db
  
  ```
  
  **Tags:** docker-compose
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-07-12. Score: 1
  
  You need to specify the container name (which is a variable, called CONTAINER\_NAME here), you might want to call it postgres\_server or something like that:
  
  ```
  version: "3.7"
  services:
    CONTAINER_NAME:
     image:  postgres
     environment:
       - POSTGRES_DB=postgres
       - POSTGRES_USER=postgres
       - POSTGRES_PASSWORD=postgres
  
     build: .
     command: python manage.py runserver 0.0.0.0:8000
     volumes:
       - .:/app
     ports:
       - "8000:8000"
     depends_on:
       - db
  
  ```
  
  source :
  <https://stackoverflow.com/questions/56733841/service-image-must-be-a-mapping-not-a-string>
  
  
  ---
  
  