sprintcube / docker-compose-lamp

A basic LAMP stack environment built using Docker Compose.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mysql is always restarting. "Changing ownership of '/var/lib/mysql/mysql.sock': No such file or directory"

t-franz opened this issue · comments

Describe the bug
The container status for mysql8 is "Restarting ...". I can't connect to MySQL

which Branch / PHP Version are you using ?
docker-compose.yml: Version 3
php8
mysql8

Steps to reproduce
Followed the instructions and it works in the first run:

git clone https://github.com/sprintcube/docker-compose-lamp.git
cd docker-compose-lamp
cp sample.env .env
docker-compose up -d

I can access http://localhost and phpMyAdmin at http://localhost:8080/
Then i stopped and started the containers:

docker compose stop
docker compose start

... and mysql stopped working: mysql is cycling and tries to restart.
desktop

I can access http://localhost, but it shows errors:
error

The log file for the mysql8-Container:

2022-11-01 12:34:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.31-1.el8 started.
[Multiple Times]
chown: changing ownership of '/var/lib/mysql/mysql.sock': No such file or directory
[Multiple Times]

Then i removed the content of the data-folder:
rm -rf data/*
And started it again:
docker compose start

And it works again!
How can i solve this, without loosing everything inside the data-folder?

Expected behavior
After stopping and starting the containers, everything should work the same.

Desktop (please complete the following information):
MacOS: 11.7
Docker Desktop: 4.13.0
Docker Compose: 1.29.2

docker -v
Docker version 20.10.20, build 9fdeb9c

Additional context
This seems to be a quite similar problem to #91 – but it didn't help me. (Please ignore my last comment inside that closed issue.)
I'm sorry: It's my first time with Docker. I used MAMP until now and i wanted to switch to Docker ... :-(
Thank you for your help!

I'm not able to reproduce this on macos.
Is some of our mac users able to double check pls ?

@t-franz
The following worked for me.
Add to docker-compose.yml at database:

user: mysql

Thank you for your help. I changed the lines to:

  database:
    user: mysql
    [...]

But i still can't connect to the database.
(In the meantime i changed to another environment and that is working.)

@t-franz I have the same problem, did you solve it?

@ctechdev No, i'm sorry. I switched to ddev and don't use lamp any more.

I'm not able to reproduce this on macos. Is some of our mac users able to double check pls ?

to reproduce the error just change PHPVERSION=php74
DATABASE=mysql57 in the env file, with an installation with default values the error is not generated, I'm trying to build the development environment with these variables and there is no way to make it work

I could start the stack with php74 and mysql57 without any issues. BUT if you change the settings and rebuild the images you have to delete the old data in the./data/mysqldirectory wich is mounted into the container by bind mounting. (Of course you could mount another directory too if you want to keep that files). If you don't delete that files, the new database container will get issues with that because the databases are not compatible over the diffrent versions.