Reputation: 13
version: '3.0'
services:
db:
image: mysql volumes: - db_data:/var/lib/mysql
restart: always
environment: MYSQL_ROOT_PASSWORD: 1234 MYSQL_USER: wordpress MYSQL_PASSWORD: 12345
wordpress1:
depends_on: -db
image: wordpress:latest
restart: always
ports: -"8080:80"
environment: WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpress WORDPRESS_DB_HOST: db:3306
volumes: db_data:
Error as below-
ERROR: yaml.scanner.ScannerError: while scanning a simple key in "./docker-compose.yml", line 21, column 3 could not find expected ':' in "./docker-compose.yml", line 23, column 3
Can anyone please help me to resolve this issue? I am trying to resolve since past 1 hour but getting into errors one by one
Upvotes: 0
Views: 281
Reputation: 640
The problem is probably in the definition of the wordpress1
service.
You need to add a space after the dash:
wordpress1:
depends_on:
- db
So instead of -db
you need to have - db
.
Edit:
The complete docker-compose.yml
should probably look like this:
version: '3.0'
services:
db:
image: mysql
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 1234
MYSQL_USER: wordpress
MYSQL_PASSWORD: 12345
wordpress1:
depends_on:
- db
image: wordpress:latest
restart: always
ports:
- "8080:80"
environment:
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_HOST: db:3306
volumes:
db_data:
Upvotes: 1
Reputation: 11
From docker documentation, the exact code you want to run: https://docs.docker.com/compose/wordpress/
Upvotes: 1