我正在尝试通过docker-compose启动phpserver。 我在工作目录中放了3个文件。
.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
版本:“ 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
和Dockerfile
FROM php:7.2-apache
RUN docker-php-ext-install \
pdo_mysql \
&& a2enmod
rewrite
但是我尝试运行后
docker-compose up --build
我有问题
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
我尝试将docker-compose文件版本更改为2-不起作用 我尝试使用“”和“”相同的问题。
我想成功运行服务器。
答案 0 :(得分:1)
以下两种格式有效:
格式#1
assignmentID: {
type: Number,
validate: {
validator: function (v) {
if (!v) {
return Promise.reject(false);
}
return new Promise( (resolve, reject) => {
Assignment.findById(v, (assignmentErr, assignmentDoc) => {
if(assignmentErr || !assignmentDoc){
reject(false);
}
else{
resolve(true);
}
})
});
},
message: 'Invalid assignment ID.'
}
}
格式#2
environment:
MYSQL_ROOT_PASSWORD: rootpassword
答案 1 :(得分:0)
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
用于work_dir的是一个列表。它需要一个字符串。
答案 2 :(得分:0)
我想从管理员连接到Postgres 版本:“ 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"
还有下一个错误。
SQLSTATE[08006] [7] FATAL: password authentication failed for user "root"