【发布时间】:2018-01-17 03:19:59
【问题描述】:
我需要在 Dockerfile 中设置默认时区。我有两个容器(nginx 和 php7-fpm)。
当我进入 PHP 容器的 bash 并运行 php --info | grep timezone 时,我得到:
默认时区 => UTC
date.timezone => 无价值 => 无价值
我的 dockerfile 如下:
nginx/Dockerfile:
FROM debian:jessie
RUN apt-get update && apt-get install -y nginx
ADD nginx.conf /etc/nginx/
ADD site.conf /etc/nginx/sites-available/
RUN ln -s /etc/nginx/sites-available/site.conf /etc/nginx/sites-enabled/site
RUN rm /etc/nginx/sites-enabled/default
RUN echo "upstream php-upstream { server php:9000; }" > /etc/nginx/conf.d/upstream.conf
RUN usermod -u 1000 www-data
CMD ["nginx"]
EXPOSE 80
EXPOSE 443
php-fpm/Dockerfile:
FROM php:7.0-fpm
RUN apt-get update && apt-get install -y git unzip
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer --version
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/Europe/Madrid /etc/localtime
RUN "date"
RUN docker-php-ext-install pdo pdo_mysql
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug
RUN echo "error_reporting = E_ALL" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "display_startup_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "display_errors = On" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_connect_back=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.idekey=\"PHPSTORM\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_port=9001" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
WORKDIR /var/www/site
我尝试使用类似问题的答案,但没有结果。
注意:我使用docker-compose build 和docker-compose up -d 来运行完整的堆栈,也就是this one。
【问题讨论】:
标签: php docker nginx dockerfile