mattrayner / docker-lamp

A simple LAMP image using Ubuntu, Apache, PHP and MySql in a single image
Apache License 2.0
592 stars 262 forks source link

/mysql_init.sh: Permission denied #140

Open julienberton opened 5 months ago

julienberton commented 5 months ago

Hello,

As I was trying to use the 2004-php8 version, MySQL init script is failing with a permission denied error (logs below).

PS C:\Users\julie> docker run -p "80:80" -v ${PWD}/Downloads/app:/app mattrayner/lamp:latest-2004-php8
WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested
Updating for PHP 8.0
Replacing CLI php.ini values
Editing APACHE_RUN_GROUP environment variable
Editing phpmyadmin config
Setting up MySQL directories
Allowing Apache/PHP to write to the app
Allowing Apache/PHP to write to MySQL
Editing MySQL config
=> An empty or uninitialized MySQL volume is detected in /var/lib/mysql
=> Installing MySQL ...
=> Done!
/run.sh: line 109: /mysql_init.sh: Permission denied
Starting supervisord
2024-05-27 08:29:50,056 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2024-05-27 08:29:50,060 INFO Included extra file "/etc/supervisor/conf.d/supervisord-apache2.conf" during parsing
2024-05-27 08:29:50,062 INFO Included extra file "/etc/supervisor/conf.d/supervisord-mysqld.conf" during parsing
2024-05-27 08:29:50,102 INFO RPC interface 'supervisor' initialized
2024-05-27 08:29:50,103 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2024-05-27 08:29:50,106 INFO supervisord started with pid 1
2024-05-27 08:29:51,127 INFO spawned: 'apache2' with pid 117
2024-05-27 08:29:51,149 INFO spawned: 'mysqld' with pid 119
2024-05-27 08:29:52,732 INFO success: apache2 entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2024-05-27 08:29:52,733 INFO success: mysqld entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

After investigating, it seems that the script is missing run permissions, a command like : chmod +x /mysql_init.sh seems to fix it in the shell of the container.

pzhlkj6612 commented 5 months ago

Hi, @julienberton!

After investigating, it seems that the script is missing run permissions, a command like : chmod +x /mysql_init.sh seems to fix it in the shell of the container.

Good catch!

https://github.com/mattrayner/docker-lamp/blob/fc1dd3404cca8e224dbefaad6a14e77b4b7936c1/2004/Dockerfile#L45-L58

It should be:

  # Add image configuration and scripts 
  ADD supporting_files/start-apache2.sh /start-apache2.sh 
  ADD supporting_files/start-mysqld.sh /start-mysqld.sh 
  ADD supporting_files/run.sh /run.sh 
+ # Add MySQL utils 
+ ADD supporting_files/mysql_init.sh /mysql_init.sh 
  RUN chmod 755 /*.sh 

  ...

- # Add MySQL utils 
- ADD supporting_files/mysql_init.sh /mysql_init.sh 

I don't know why this script worked fine in previous releases... I didn't encounter this issue.


@mattrayner ,

Here we have the warning:

WARNING: The requested image's platform (linux/arm64) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested

Is this related to #139 ?