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

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.