Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'./docker-compose.yml', service must be a mapping, not a NoneType

When I ran: COMPOSE_PROJECT_NAME=zk_test docker-compose up, I got error saying

"ERROR: In file './docker-compose.yml', service must be a mapping, not a NoneType.".

This is my yml file:

version: '2' services: zoo1: image: zookeeper restart: always container_name: zoo1 ports: - "2181:2181" environment: ZOO_MY_ID: 1 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888  zoo2: image: zookeeper restart: always container_name: zoo2 ports: - "2182:2181" environment: ZOO_MY_ID: 2 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888  zoo3: image: zookeeper restart: always container_name: zoo3 ports: - "2183:2181" environment: ZOO_MY_ID: 3 ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888 

Sample Image:

Sample Image

like image 643
champin hwang Avatar asked Apr 17 '17 13:04

champin hwang


2 Answers

YAML is indentation dependent. This

services: zoo1: 

is a mapping with two keys that both map to null (i.e. None in Python).

Whereas:

services:    zoo1: 

is a mapping nested in a mapping. The key 'services' has as value a mapping with key zoo1 (which again has a value null).

like image 109
Anthon Avatar answered Oct 13 '22 18:10

Anthon


version: '2'                                                                     services:                                                                             autodiscovery:                                                                      build: ./autodiscovery/                                                             mem_limit: 128m                                                                     expose:                                                                               - 53                                                                                - 8300                                                                              - 8301                                                                              - 8302                                                                              - 8400                                                                              - 8500                                                                            ports:                                                                                - 8500:8500                                                                       dns:                                                                                  - 127.0.0.1   

just put one space. before.

like image 39
Tshepho Boya Avatar answered Oct 13 '22 18:10

Tshepho Boya