Reputation: 2417
I have created a docker-compose file that will start up Kabana and ElasticSearch containers. I already have created a network and volume for these in my VM. I am using docker compose version 3.4.
Command: docker volumes ls
DRIVER VOLUME NAME
local elasticsearch-data
local portainer_data
Command: docker volumes ls
NETWORK ID NAME DRIVER SCOPE
75464cd8c8ab bridge bridge local
587a311f6f4f host host local
649ac00b7f93 none null local
4b5923b1d144 stars.api.web bridge local
Command: docker-compose up -d
ERROR: yaml.scanner.ScannerError: mapping values are not allowed here
in "./docker-compose.yml", line 33, column 27
docker-compose.yml
version: '3.4'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
container_name: elasticsearch
ports:
- "9200:9200"
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
networks:
- stars.api.web
environment:
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
ELASTIC_PASSWORD: changeme
discovery.type: single-node
ulimits:
memlock:
soft: -1
hard: -1
kibana:
image: docker.elastic.co/kibana/kibana:7.6.0
container_name: kibana
ports:
- "5601:5601"
depends_on:
- elasticsearch
networks:
- stars.api.web
volumes:
name: elasticsearch-data:
networks:
name: stars.api.web:
EDIT:
removing the :
from the name, eg name: elasticsearch-data
throws the following error:
ERROR: In file './docker-compose.yml', volume 'name' must be a mapping not a string.
Upvotes: 0
Views: 1148
Reputation: 916
In addition, a nice trick to check if you Compose file is valid:
docker-compose -f file config
If the alternate file is omitted will take docker-compose.yml
as default.
from the help page:
config: Validate and view the Compose file
After applying the suggested edits by @leopal, If you want a "quite" output,
$ docker-compose -f docker-compose.yaml config -q
$ docker-compose -f your.yaml config
networks:
stars.api.web: {}
services:
elasticsearch:
container_name: elasticsearch
environment:
ELASTIC_PASSWORD: changeme
ES_JAVA_OPTS: -Xmx256m -Xms256m
discovery.type: single-node
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
networks:
stars.api.web: null
ports:
- published: 9200
target: 9200
ulimits:
memlock:
hard: -1
soft: -1
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data:rw
kibana:
container_name: kibana
depends_on:
- elasticsearch
image: docker.elastic.co/kibana/kibana:7.6.0
networks:
stars.api.web: null
ports:
- published: 5601
target: 5601
version: '3.4'
volumes:
elasticsearch-data: {}
Upvotes: 1
Reputation: 4959
Your yaml is invalid according to the docs.
Please use the following compose file:
version: '3.4'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.0
container_name: elasticsearch
ports:
- "9200:9200"
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
networks:
- stars.api.web
environment:
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
ELASTIC_PASSWORD: changeme
discovery.type: single-node
ulimits:
memlock:
soft: -1
hard: -1
kibana:
image: docker.elastic.co/kibana/kibana:7.6.0
container_name: kibana
ports:
- "5601:5601"
depends_on:
- elasticsearch
networks:
- stars.api.web
volumes:
elasticsearch-data:
external: true
networks:
stars.api.web:
I assume that you have already created defined volume and network. Note that external: true
is required when the volume has been created outside of docker-compose context.
Upvotes: 1