version: '3.0'
services:
db:
image: mysql:5.7
container_name: mysql_database
volumes:
-db_data: /var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: word@poress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: abc@123y
wordpress:
depends_on:
-db
image: wordpress:latest
container_name:wd_frontend
volumes:
-wordpress_files: /var/www/html
port:
-"8000:80"
restart: always
volumes:
wordpress_files:
db_data:
services:
- db
- wordpress
Ths is the offending part that results in the error message.
A cleaned up version of you compose file could look like this:
version: '2.4'
services:
db:
image: mysql:5.7
container_name: mysql_database
restart: always
volumes:
- db_data: /var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: word@poress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: abc@123y
wordpress:
image: wordpress:latest
container_name: wd_frontend
restart: always
volumes:
- wordpress_files: /var/www/html
port:
- "8000:80"
depends_on:
- db
volumes:
wordpress_files: {}
db_data: {}
I am not a fan of using schema version 3.0 or higher when the deployment is targeting docker-compose. With docker swarm deployments, using 3.8 or 3.9 makes sense.
Though, this is basic yaml skill, which every better editor like visual studio code, notepad++, sublime text3, and many other should validate for you one the fly. The rest is looking up syntax from the official docker compose reference documentation. There is no need to guess here. This is realy the very basic.
Thank you very much for your help, even removing that part and changing the version and removing spaces as you guessed, the file still getting error services must be a mapping
I just restructed your yaml, but missed that you used “port” instead of “ports”.
I always find it astonishing that beginners decide what parts of an error message are relevant for others to help. You managed to boil it down to a single sentence that doesn’t make sense to.
Good luck with finding a solution!
you helped , thank you