Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chown: changing ownership of '/var/lib/mysql/': Operation not permitted #149

Closed
laeeq80 opened this issue Jan 17, 2018 · 4 comments
Closed

Comments

@laeeq80
Copy link

laeeq80 commented Jan 17, 2018

I am using mariadb:10.2.12 docker image and want to deploy on openshift origin. I get following error on openshift origin. Works perfectly on local. Is their a way to get around for this issue or I would need to built a custom image of mariadb? I am running as non-root. Following is my docker file.

FROM mariadb:10.2.12

ENV MYSQL_DATABASE="db_profile"

COPY ./my.cnf /etc/mysql/my.cnf
COPY ./db_profile.sql /docker-entrypoint-initdb.d/

RUN adduser mysql root

USER mysql

EXPOSE 3306

Error:

Initializing database
chown: changing ownership of '/var/lib/mysql/': Operation not permitted
Cannot change ownership of the database directories to the 'mysql'
user. Check that you have the necessary permissions and try again.

@yosifkit
Copy link
Contributor

The chown error you are seeing must be coming from mysql_install_db. It is probably detecting that the directory mounted at /var/lib/mysql is not owned by mysql and trying to fix that (which doesn't work because it is not root).

https://github.com/docker-library/mariadb/blob/a1f61de0bb84ed1b4a482361c6aa8b8f4398f5cc/10.2/docker-entrypoint.sh#L90-L91

In the default setup of the image we start the container as root, automatically fix volume permissions, and then step down to the mysql user to finish setup and run mysqld.

https://github.com/docker-library/mariadb/blob/a1f61de0bb84ed1b4a482361c6aa8b8f4398f5cc/10.2/docker-entrypoint.sh#L66-L72

Since you are starting the container as non-root (which is a valid and supported use case since #59), you are responsible for ensuring that the volume has correct permissions for the user that you are running as.

Since this seems more like a problem with your openshift configuration and not a problem with the image, I'll close the issue.

In the future, it'd be better to post questions like this in the Docker Community Forums, the Docker Community Slack, or Stack Overflow.

@laeeq80
Copy link
Author

laeeq80 commented Jan 18, 2018

Once the Volume is set, chmod/chown does not take effect. link

So I can't change permissions.

@tianon
Copy link
Contributor

tianon commented Jan 18, 2018 via email

@lingxiankong

This comment has been minimized.

@MariaDB MariaDB locked as resolved and limited conversation to collaborators May 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

4 participants