Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to deploy a mariadb image on openshift origin. I am using mariadb:10.2.12 in my docker file. It works ok on local but I get following error when I try to deploy on openshift origin.

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.

The chown command comes from mariadb:10.2.12 Docker file.

Initially I had the issue of root user which is not allowed on openshift origin, so now I am using

USER mysql

in the docker file. Now I don't get warning of running as root but still openshift origin don't like chown. Remember I am not the admin of origin, only a user. My docker file is as follows:

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/

USER mysql

EXPOSE 3306

and on local I run it as follows:

docker build . -t laeeq/ligandprofiledb:0.0.1

docker run --name test-mysql -e MYSQL_ROOT_PASSWORD=mypassword -d laeeq/ligandprofiledb:0.0.1

Is there a workaround to solve this chown problem?

like image 371
Laeeq Avatar asked Nov 18 '22 22:11

Laeeq


1 Answers

The MariaDB images on DockerHub don't follow good practice of not requiring to be run as root user.

You should instead use the MariaDB images provided by OpenShift. Eg:

centos/mariadb-102-centos7

See:

  • https://github.com/sclorg/mariadb-container

There should be an ability to select MariaDB from the service catalog browser in the OpenShift web console, or use the mariadb template from the command line.

like image 179
Graham Dumpleton Avatar answered Dec 04 '22 03:12

Graham Dumpleton