1

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

Peter Turner
  • 1,430
  • 4
  • 17
  • 35
user36023
  • 11
  • 3

1 Answers1

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

Peter Turner
  • 1,430
  • 4
  • 17
  • 35
tintin
  • 101
  • 3