Hi people I want to create separate projects, where each project is fully isolated from the others. Meaning that each project will get a local network and volume for services like mysql and/or redis. Since I’m not too great with docker, I encountered a mysql error and can’t seem to get rid of it.
I searched google for a good day, and can’t seem to find an answer, except (Remove the image, volumes, blablabla of the old project, but I’m still using it, so I don’t want to remove it, I want to be able to work on 2 - 3 or 7 projects if needed).
If anyone can help that would be much appreciated… I am wondering what I’m doing wrong, or maybe I don’t know the Docker best practices.
Here are two docker-compose files of my 2 projects I was talking about. They are almost identical:
PROJECT 1:
version: "3"
networks:
tng:
services:
nginx:
image: nginx:stable-alpine
container_name: tng-nginx
ports:
- "80:80"
volumes:
- ../:/var/www/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
networks:
- tng
php:
build:
context: ""
dockerfile: php/php-Dockerfile
container_name: tng-php
volumes:
- ../:/var/www/html
ports:
- "9000:9000"
depends_on:
- mysql
- redis
networks:
- tng
mysql:
image: mysql:8.0.30-oracle
container_name: tng-mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
tty: true
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: 111
networks:
- tng
redis:
image: redis:alpine
container_name: tng-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- ./redis:/data
networks:
- tng
PROJECT 2:
version: "3"
networks:
laravel:
services:
nginx:
image: nginx:stable-alpine
container_name: kuts-nginx
ports:
- "80:80"
volumes:
- ../:/var/www/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
networks:
- laravel
php:
build:
context: ""
dockerfile: php/php-Dockerfile
container_name: kuts-php
volumes:
- ../:/var/www/html
ports:
- "9000:9000"
depends_on:
- mysql
- redis
networks:
- laravel
mysql:
image: mysql:8.0.30-oracle
container_name: kuts-mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
tty: true
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: 111
networks:
- laravel
redis:
image: redis:alpine
container_name: kuts-redis
restart: unless-stopped
ports:
- "6379:6379"
volumes:
- ./redis:/data
networks:
- laravel
THE mysql ERROR:
tng-mysql | 2023-04-22 23:38:36+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
tng-mysql | 2023-04-22 23:38:36+00:00 [Note] [Entrypoint]: Switching to dedicated user ‘mysql’
tng-mysql | 2023-04-22 23:38:36+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
tng-mysql | ‘/var/lib/mysql/mysql.sock’ → ‘/var/run/mysqld/mysqld.sock’
tng-mysql | 2023-04-22T23:38:36.843528Z 0 [Warning] [MY-011068] [Server] The syntax ‘–skip-host-cache’ is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
tng-mysql | 2023-04-22T23:38:36.847140Z 0 [Warning] [MY-010918] [Server] ‘default_authentication_plugin’ is deprecated and will be removed in a future release. Please use authentication_policy instead.
tng-mysql | 2023-04-22T23:38:36.847157Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
tng-mysql | 2023-04-22T23:38:36.850895Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
tng-mysql | 2023-04-22T23:38:36.857748Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
tng-mysql | 2023-04-22T23:38:36.887982Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create redo log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
tng-mysql | 2023-04-22T23:38:37.375378Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
tng-mysql | 2023-04-22T23:38:37.375566Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
tng-mysql | 2023-04-22T23:38:37.375663Z 0 [ERROR] [MY-010119] [Server] Aborting
tng-mysql | 2023-04-22T23:38:37.376474Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30) MySQL Community Server - GPL.
P.S. Note: I don’t have any issues doing “docker-compose up” on project 2. I’m having issues when I do “docker-compse up” on the first project.