Pour une raison quelconque, j'étais accro au phénomène selon lequel la base de données de test Docker se terminait par la sortie 1, alors j'ai pris note.
src $ docker-compose ps
Name Command State Ports
-----------------------------------------------------------------------------------
db docker-entrypoint.sh Up 0.0.0.0:3307->3306/tcp
mysqld , 33060/tcp
db-testing docker-entrypoint.sh Exit 1
mysqld
docker-laravel_app_1 docker-php-entrypoint Up 0.0.0.0:18000->8000/tc
php-fpm p, 9000/tcp
docker-laravel_https- /init Exit 0
portal_1
docker-laravel_web_1 nginx -g daemon off; Up 0.0.0.0:10080->80/tcp
MacBook Air 2019 (core-i5, RAM16GB) Laravel7 Docker for Desktop 2.3.0.4 Docker version 19.03.12 Docker-compose version 1.26.2
docker-compose.yml
version: "3"
services:
db:
build:
context: ./docker/mysql
container_name: db
volumes:
- db-store:/var/lib/mysql
- db-logs-store:/var/log/mysql
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
environment:
- MYSQL_DATABASE=${DB_NAME:-JETmysql}
- MYSQL_USER=${DB_USERNAME:-root}
- MYSQL_PASSWORD=${DB_PASS:-secret}
- MYSQL_ROOT_PASSWORD=${DB_PASS:-secret}
- TZ=${TZ:-Asia/Tokyo}
ports:
- ${DB_PORT}:3306
db-testing:
image: mysql:8.0
container_name: db-testing
volumes:
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
tmpfs:
- /var/lib/mysql
- /var/log/mysql
environment:
- MYSQL_DATABASE=${DB_NAME:-JETmysql}
- MYSQL_USER=${DB_USERNAME:-root}
- MYSQL_PASSWORD=${DB_PASS:-secret}
- MYSQL_ROOT_PASSWORD=${DB_PASS:-secret}
- TZ=${TZ:-Asia/Tokyo}
ports:
- ${DB_TESTING_PORT}:3306
volumes:
db-logs-store:
db-store:
redis-store:
À première vue, cela semblait aller, mais avec cela, le journal n'a pas pu être écrit et une erreur d'autorisation s'est produite.
src $ docker logs db-testing
2020-09-05 16:31:21+09:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
2020-09-05 16:31:22+09:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-09-05 16:31:22+09:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
2020-09-05 16:31:22+09:00 [Note] [Entrypoint]: Initializing database files
2020-09-05T16:31:22.412681+09:00 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.21) initializing of server in progress as process 43
2020-09-05T16:31:22.420005+09:00 0 [ERROR] [MY-010187] [Server] Could not open file '/var/log/mysql/mysql-error.log' for error logging: No such file or directory
2020-09-05T16:31:22.420889+09:00 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2020-09-05T16:31:22.421233+09:00 0 [ERROR] [MY-010119] [Server] Aborting
2020-09-05T16:31:22.421572+09:00 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.21) MySQL Community Server - GPL.
Pour éviter cela, écrivez l'autorisation cmd dans le Dockerfile.
FROM mysql:8.0
RUN mkdir /var/log/mysql
RUN chown mysql:mysql /var/log/mysql
Commentez l'image et chargez le Dockerfile.
docker-compose.yml
db-testing:
# image: mysql:8.0
build:
context: ./docker/mysql
dockerfile: Dockerfile.test
Je pensais que cela réglerait le problème, mais une autre erreur s'est produite.
2020-09-05 16:37:43+09:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2020-09-05 16:37:53+09:00 [Note] [Entrypoint]: Creating database JETmysql
2020-09-05 16:37:53+09:00 [Note] [Entrypoint]: Creating user root
ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'root'@'%'
Impossible de créer un utilisateur car le fuseau horaire est incorrect? ?? J'ai pensé, mais je l'ai manqué.
docker-compose.yml
db-testing:
# image: mysql:8.0
build:
context: ./docker/mysql
dockerfile: Dockerfile.test
container_name: db-testing
volumes:
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
tmpfs:
- /var/lib/mysql
# - /var/log/mysql
environment:
- MYSQL_DATABASE=${DB_NAME:-JETmysql}
# - MYSQL_USER=${DB_USERNAME:-root}
- MYSQL_PASSWORD=${DB_PASS:-secret}
- MYSQL_ROOT_PASSWORD=${DB_PASS:-secret}
- TZ=${TZ:-Asia/Tokyo}
ports:
- ${DB_TESTING_PORT}:3306
Un avertissement est toujours émis. .. Cela a commencé pour le moment.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2020-09-05 16:45:50+09:00 [Note] [Entrypoint]: Creating database JETmysql
2020-09-05 16:45:50+09:00 [Note] [Entrypoint]: Stopping temporary server
2020-09-05 16:45:53+09:00 [Note] [Entrypoint]: Temporary server stopped
2020-09-05 16:45:53+09:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
Selon ce qui suit, car vous avez déjà spécifié l'utilisateur root quelque part Si vous le spécifiez à nouveau, une erreur se produira. C'est vrai que db le spécifie, mais je ne comprends pas la raison car les conteneurs ne doivent pas interférer les uns avec les autres. .. https://github.com/docker-library/mysql/issues/129#issuecomment-178265632
Si quelqu'un sait, faites-le moi savoir.
Recommended Posts