Reputation: 105
I am trying to up phpserver via docker-compose. I put 3 files in my working directory.
.env docker-compose.yml Dockerfile
.env
##PATHS
DB_PATH_HOST=./databases
APP_PATH_HOST=./blog
APP_PATH_CONTAINER=/var/www/html/
MYSQL_ROOT_PASSWORD=123456
docker-compose.yml
version: '3'
services:
web:
build: .
environment:
- APACHE_RUN_USER=www-data
volumes:
- ${APP_PATH_HOST}: ${APP_PATH_CONTAINER}
ports:
- 8080:80
working_dir:
- ${APP_PATH_CONTAINER}
db:
image: mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
volumes:
- ${DB_PATH_HOST}: /var/lib/mysql
adminer:
image: adminer
restart: always
ports:
- 6080:8080
composer:
image: composer:1.7
volumes:
- ${APP_PATH_HOST}: ${APP_PATH_CONTAINER}
working_dir: ${APP_PATH_CONTAINER}
command: composer install
and Dockerfile
FROM php:7.2-apache
RUN docker-php-ext-install \
pdo_mysql \
&& a2enmod
rewrite
But after I try to run
docker-compose up --build
I have the problem
ERROR: The Compose file '.\docker-compose.yml' is invalid because:
services.web.working_dir contains an invalid type, it should be a string
services.composer.volumes contains an invalid type, it should be a string
services.web.volumes contains an invalid type, it should be a string
services.db.volumes contains an invalid type, it should be a string
I tried to change docker-compose file version to 2 - does not work I tried to use '' and "" the same problem.
I want to run my server successfully.
Upvotes: 2
Views: 9019
Reputation: 1190
The following two formats work:
Format #1
environment:
MYSQL_ROOT_PASSWORD: rootpassword
Format #2
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
Upvotes: 8
Reputation: 105
I want to connect to from adminer to postgres version: '3'
services:
web:
build: .
environment:
- APACHE_RUN_USER=www-data
volumes:
- ./blog:/var/www/html/
ports:
- 8080:80
working_dir: /var/www/html/
db:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: kisphp
POSTGRES_USER: root
POSTGRES_DB: kisphp
ports:
- "5432:5432"
volumes:
- ./postgres:/var/lib/postgresql/data
adminer:
image: adminer
restart: always
ports:
- "6080:8080"
and I have next error.
SQLSTATE[08006] [7] FATAL: password authentication failed for user "root"
Upvotes: 0
Reputation: 10737
version: "3.3"
services:
web:
build: .
environment:
- APACHE_RUN_USER=www-data
volumes:
- "${APP_PATH_HOST}: ${APP_PATH_CONTAINER}"
ports:
- 8080:80
working_dir: ${APP_PATH_CONTAINER}
db:
image: mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
volumes:
- "${DB_PATH_HOST}:/var/lib/mysql"
adminer:
image: adminer
restart: always
ports:
- 6080:8080
composer:
image: composer:1.7
volumes:
- "${APP_PATH_HOST}: ${APP_PATH_CONTAINER}"
working_dir: ${APP_PATH_CONTAINER}
command: composer install
What you used for working_dir was a list. It needed a string.
Upvotes: 3