Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Top level object in './docker-compose.yml' needs to be an object not '<class 'NoneType'>'

I'm using python 3.8, Docker version 19.03.13, build 4484c46d9d 3.8

version: '3.8'
services:
  web:
    build: .
    command: python /code/manage.py runserver 0.0.0.0:8000
  volumes:
    - .:/code
  ports:
    - 8000:8000
like image 437
Hesham Mahmoud Avatar asked Oct 23 '20 15:10

Hesham Mahmoud


People also ask

Do you need Dockerfiles with Docker compose?

Thanks in advance. You re right, Dockerfile is not necessary. Docker Compose uses YAML file, typically named docker-compose. yml to define what your mutliple-container application should look like.

How do I validate a Docker compose file?

Validating your file now is as simple as docker-compose -f docker-compose. yml config . As always, you can omit the -f docker-compose. yml part when running this in the same folder as the file itself or having the COMPOSE_FILE environment variable pointing to your file.

What is Docker compose override yml?

The docker-compose. override. yml is the configuration file where you can override existing settings from docker-compose. yml or even add completely new services. By default, this file does not exist and you must create it.

What does Docker compose yml do?

A docker-compose. yml is a config file for Docker Compose. It allows to deploy, combine, and configure multiple docker containers at the same time. The Docker "rule" is to outsource every single process to its own Docker container.


3 Answers

Maybe docker-compose.yml is empty

like image 169
hamze_z3 Avatar answered Oct 27 '22 04:10

hamze_z3


Your .yml file must be empty. Try saving the file.

like image 19
Usman Avatar answered Oct 27 '22 04:10

Usman


If you have just created your docker-compose.yml chances are you haven't saved it and hit docker-compose up.

Save it and try again. It should work fine

like image 6
Ketan Avatar answered Oct 27 '22 02:10

Ketan