I am working on a php docker application.Am facing an error while trying docker-compose up command. Trying to connect a php application to mysql.
My docker compose file :-
version: '2'
services:
web:
container_name: modeloPHP5.4-Apache
build: .
ports:
— 8889:80
volumes:
— ./www:/var/www/html
links:
— db
db:
container_name: modeloMySQL
build:
context: ./
dockerfile: DockerfileDB
volumes:
— /var/lib/mysql
ports:
— 3307:3306
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: db_test
Docker compose files are YAML files that require indentation, due to a wrong indentation in your compose file, Docker thinks that build is a service declaration. You've a similar question here and you can follow an example in Docker docs to check how the indentation works.
docker-compose file is using the YAML format, so you must check every space, line, new line and other syntax is correct in yaml format. you can use yaml parser to help you to check docker-compose file.
version: '2'
services:
web:
container_name: modeloPHP5.4-Apache
build: .
ports:
- 8889:80
volumes:
- ./www:/var/www/html
links:
- db
db:
container_name: modeloMySQL
build:
context: ./
dockerfile: DockerfileDB
volumes:
- /var/lib/mysql
ports:
- 3307:3306
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: db_test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With