In the docker-compose.yml
files, why are certain enumerations done with a dash -
, and others without?
services:
web: # the enumeration of [build, ports, volumes, environment] doesn't use a -
build: .
ports:
- "5000:5000" # why the - here? could we remove it and have ports: "5000:5000"?
volumes:
- .:/code # why the - here?
environment:
FLASK_ENV: development # why no - here?
redis:
image: "redis:alpine"
Another example:
version: '2'
services:
db:
image: mysql:5.7
volumes:
- ./mysql:/var/lib/mysql # could we remove this - prefix?
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress # no - in this enumeration, why?
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db # would it be ok without - ?
image: wordpress:latest
volumes:
- ./wp:/var/www/html # same
...