https://qiita.com/ucan-lab/items/5fc1281cd8076c8ac9f4
When I cloned this god repository and tried to use it, Since TimeZone was UTC, it will be a memorandum when it is corrected to Japan time.
Modify the Dockerfile in the configuration below. When implementing for those who have launched a container, Correct the Dockerfile when the container is stopped and rebuild it.
├── backend #Laravel project root directory
├── infra
│ └── docker
│ ├── mysql
│ │ ├── Dockerfile
│ │ └── my.cnf
│ ├── nginx
│ │ ├── Dockerfile
│ │ └── default.conf
│ └── php
│ ├── Dockerfile
│ ├── php-fpm.d
│ │ └── zzz-www.conf =>unix domain socket configuration file
│ └── php.ini
├── Makefile
└── docker-compose.yml
mysql
docker-laravel\infra\docker\mysql\Dockerfile
#Change ENV TZ (near the 4th line)
# ENV TZ=UTC \
ENV TZ=Asia/Tokyo \
It will be the work after build and container start-up (up) are completed.
shell
$ make db
# $ docker-compose exec db bash (Contents of the above make command)
root@XXXXXXX:# mysql -u root -p -h 127.0.0.1
Enter password: secret
#Please enter the PW near the 8th line described in the Dockerfile.
# MYSQL_ROOT_PASSWORD=secret
#  ̄ ̄ ̄ ̄
mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | JST |
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set (0.01 sec)
If JST is displayed in system_time_zone, there is no problem.
nginx
docker-laravel\infra\docker\nginx\Dockerfile
#Change ENV TZ (near line 6)
# ENV TZ=UTC
ENV TZ=Asia/Tokyo
It will be the work after build and container start-up (up) are completed.
shell
$ make web
# $ docker-compose exec web ash (Contents of the above make command)
/work/backend# date
If the current time is displayed, there is no problem.
php
docker-laravel\infra\docker\php\Dockerfile
#Change the timezone environment (near the 5th line)
# ENV TZ=UTC \
# locale
# LANG=en_US.UTF-8 \
# LANGUAGE=en_US:en \
# LC_ALL=en_US.UTF-8 \
ENV TZ=Asia/Tokyo \
# locale
LANG=ja_JP.UTF-8 \
LANGUAGE=ja_JP:ja \
LC_ALL=ja_JP.UTF-8 \
docker-laravel\infra\docker\php\Dockerfile
#Change local settings (near line 36)
# locale-gen en_US.UTF-8 && \
# localedef -f UTF-8 -i en_US en_US.UTF-8 && \
locale-gen ja_JP.UTF-8 && \
localedef -f UTF-8 -i ja_JP ja_JP.UTF-8 && \
It will be the work after build and container start-up (up) are completed.
shell
$ make app
# $ docker-compose exec app bash (Contents of the above make command)
root@XXXXXXX:/work/backend# php -r 'echo date("Y/m/d H:i:s"),PHP_EOL;'
If the current time is displayed, there is no problem.
This completes the response. I hope it helps someone.
If you have any mistakes or better repair methods, please let us know in the comments. Thank you.
Recommended Posts