我有一个自定义php应用程序在docker上运行。我已经设置了一些用于配置php.ini或apache的环境变量,但是当我做docker-compose up --build
并尝试从浏览器访问应用程序(index.php)时,我可以看到环境变量并未覆盖php。 .ini文件或apache conf。有什么想法我做错了吗?
这些是我的文件
docker-compose.yml
services:
app:
container_name: myapp
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- .:/var/www/html
ports:
- 8080:80
env_file:
- ./.env
networks:
- appnet
Dockerfile
FROM php:7.3-apache-stretch
COPY docker/vhost.conf /etc/apache2/sites-available/000-default.conf
COPY docker/config/php/php.ini /usr/local/etc/php/php.ini
COPY docker/config/php/conf.d/*.ini /usr/local/etc/php/conf.d/
COPY . /var/www/html/
WORKDIR /var/www/html/
php.ini
date.timezone = ${PHP_DATE_TIMEZONE}
display_errors = ${PHP_DISPLAY_ERRORS}
error_reporting = ${PHP_ERROR_REPORTING}
.env
PHP_DATE_TIMEZONE = Europe/London
PHP_DISPLAY_ERRORS = 1
PHP_ERROR_REPORTING = -1
index.php
答案 0 :(得分:0)
问题是您的def teams = ['x', 'y', 'z']
def list = [ [id:1, team1: 'x', team2:'y' ], [id:2, team1: 'z', team2:'y' ]]
def function = { closure -> teams.inject( [:]) { result, team -> result[team] = list.findAll(closure.curry(team)).size() ; result } }
def t = { param1, it -> param1 in [it.team1, it.team2] }
println function(t)
文件中有空格。
尝试将其更改为:
.env
Compose希望环境文件中的每一行都是VAR = VAL格式。