containers icon indicating copy to clipboard operation
containers copied to clipboard

Container not starting '/opt/bitnami/mysql/conf/my.cnf' is not writable'

Open anatol06 opened this issue 1 year ago • 4 comments

Name and Version

bitnami/mysql:8.1.0-debian-11-r57

What architecture are you using?

amd64

What steps will reproduce the bug?

saving the settings in starting the container in Plesk Obsidian. The mapping is set in this way:

/bitnami/mysql/data			/var/docker/mysql81
/opt/bitnami/mysql/conf		/var/docker/mysql81_config

What is the expected behavior?

the container does not start

What do you see instead?

The log in Plesk:

Container does not start: The log:

[38;5;6mmysql [38;5;5m10:26:04.61 [0m
[38;5;6mmysql [38;5;5m10:26:04.61 [0m[1mWelcome to the Bitnami mysql container[0m
[38;5;6mmysql [38;5;5m10:26:04.61 [0mSubscribe to project updates by watching [1mhttps://github.com/bitnami/containers[0m
[38;5;6mmysql [38;5;5m10:26:04.61 [0mSubmit issues and feature requests at [1mhttps://github.com/bitnami/containers/issues[0m
[38;5;6mmysql [38;5;5m10:26:04.61 [0m
[38;5;6mmysql [38;5;5m10:26:04.62 [0m[38;5;2mINFO [0m ==> ** Starting MySQL setup **
[38;5;6mmysql [38;5;5m10:26:04.63 [0m[38;5;2mINFO [0m ==> Validating settings in MYSQL_*/MARIADB_* env vars
[38;5;6mmysql [38;5;5m10:26:04.63 [0m[38;5;2mINFO [0m ==> Initializing mysql database
[38;5;6mmysql [38;5;5m10:26:04.64 [0m[38;5;3mWARN [0m ==> The mysql configuration file '/opt/bitnami/mysql/conf/my.cnf' is not writable. Configurations based on environment variables will not be applied for this file.
[38;5;6mmysql [38;5;5m10:26:04.64 [0m[38;5;2mINFO [0m ==> Installing database
[38;5;6mmysql [38;5;5m10:26:05.07 [0m
[38;5;6mmysql [38;5;5m10:26:05.08 [0m[1mWelcome to the Bitnami mysql container[0m
[38;5;6mmysql [38;5;5m10:26:05.08 [0mSubscribe to project updates by watching [1mhttps://github.com/bitnami/containers[0m
[38;5;6mmysql [38;5;5m10:26:05.08 [0mSubmit issues and feature requests at [1mhttps://github.com/bitnami/containers/issues[0m
[38;5;6mmysql [38;5;5m10:26:05.08 [0m
[38;5;6mmysql [38;5;5m10:26:05.08 [0m[38;5;2mINFO [0m ==> ** Starting MySQL setup **
[38;5;6mmysql [38;5;5m10:26:05.09 [0m[38;5;2mINFO [0m ==> Validating settings in MYSQL_*/MARIADB_* env vars

Additional information

Ubuntu 20.04.6 LTS Plesk Obsidian Version 18.0.60

anatol06 avatar May 13 '24 10:05 anatol06

These are settings in Plesk:

image

I have set the permissions for /var/docker/mysql81 and /var/docker/mysql81_config on ubuntu to 755 and now the container starts but just in background, the DBs are not avaiable.

image

Here are the settings for a MySQL 8.0 container from MySQL which works perfectly but there are some strange warnings in logs and for this reason I would like to switch to bitnami:

image

anatol06 avatar May 13 '24 12:05 anatol06

Could you increase the logs' verbosity by setting the BITNAMI_DEBUG environment variable to true? Just in case it helps to detect the source of the issue.

carrodher avatar May 14 '24 07:05 carrodher

After much research, I discovered that Bitnami containers are non-root containers, started by default with a non-root user. The mounted files and directories must have the proper permissions for the UID 1001. To make everything working properly I did in this way (if there are better solutions, please share):

Image: bitnami/mysql:8.0.36-debian-11-r20

Create directories on Ubuntu and set the rights:

cd /var/docker
mkdir mysql80 mysql80_config
sudo chmod -R 775 mysql80 mysql80_config

Create a file for custom MySQL settings:

touch mysql80_config/my_custom.cnf  

The name "my_custom.cnf" is specified in Bitnami documentation. The app is looking for a file with such a name.

Container settings in Plesk Obsidian:

image

Timezone: 'Europe/Berlin' is not accepted in my.cnf in this way:

[mysqld]
default_time_zone='Europe/Berlin'

When is set like this, the container starts in bakground and the quotes ('Europe/Berlin') are lost after container restart (I tested it in my.cnf, not in my_custom.cnf). So I found another way - to set it as variable in Plesk, see the screenshot.

Is there any way to run the container as "root" using environment variable as I did for timezone?

anatol06 avatar May 14 '24 08:05 anatol06

Yes, as you rightly said, Bitnami containers are designed to operate as non-root by default. Consequently, any files or directories used by the application should be owned by the root group, as the random user (1001 by default) is a member of this root group. To ensure proper permissions, you'll need to adjust the ownership of your local directory accordingly.

For more comprehensive information about non-root containers and their significance for security, you can explore the following resources:

These references provide valuable insights into the best practices and considerations when working with non-root containers in Bitnami applications.

carrodher avatar May 14 '24 10:05 carrodher

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] avatar May 30 '24 01:05 github-actions[bot]

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

github-actions[bot] avatar Jun 04 '24 01:06 github-actions[bot]