Skip to content

Cannot run mariadb docker container as an arbitrary user #304

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

Closed
lingxiankong opened this issue May 12, 2020 · 2 comments
Closed

Cannot run mariadb docker container as an arbitrary user #304

lingxiankong opened this issue May 12, 2020 · 2 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@lingxiankong
Copy link

lingxiankong commented May 12, 2020

I was running mariadb docker container (image mariadb:10.4.12) by specifying --user UID:GID -v /var/lib/mysql:/var/lib/mysql and the ownership of /var/lib/mysql is UID:GID. The command was running as a non-root user, but failed with the error:

2020-05-12 11:16:43+00:00 [Note] [Entrypoint]: Initializing database files
chown: changing ownership of '/var/lib/mysql/data/': Operation not permitted
Cannot change ownership of the database directories to the 'mysql'
user.  Check that you have the necessary permissions and try again.

MySQL docker image supports this, see https://hub.docker.com/_/mysql, Running as an arbitrary user.

I also found #59, seems it should support this feature, is there anything I am missing?

@wglambert wglambert added the question Usability question, not directly related to an error with the image label May 12, 2020
@wglambert
Copy link

I can't reproduce, even with 700 permissions. Can you give all the commands you ran and any relevant files or logs for reproducing the issue?

$ adduser -u 1337 test

$ mkdir mysql

$ chmod 700 mysql

$ docker run -d -e MYSQL_ROOT_PASSWORD=pass --name mariadb --user 1337 -v "$PWD"/mysql:/var/lib/mysql mariadb
82e83d67928a4bbcb9cb69be8a18ee0fe8c3feec51c5cea03d3db77a55122454

$ docker logs mariadb 2>&1 | tail -n 5
2020-05-12 16:02:19 0 [Warning] 'proxies_priv' entry '@% root@82e83d67928a' ignored in --skip-name-resolve mode.
2020-05-12 16:02:19 0 [Note] Reading of all Master_info entries succeeded
2020-05-12 16:02:19 0 [Note] Added new Master_info '' to hash table
2020-05-12 16:02:19 0 [Note] mysqld: ready for connections.
Version: '10.4.12-MariaDB-1:10.4.12+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution

$ docker exec -it mariadb bash

I have no name!@82e83d67928a:/var/lib/mysql$ echo $UID
1337

I have no name!@82e83d67928a:/$ cd /var/lib

I have no name!@82e83d67928a:/var/lib$ ls -al
total 0
drwxr-xr-x 1 root root  57 Apr 24 20:08 .
drwxr-xr-x 1 root root  41 Apr  3 17:14 ..
drwxr-xr-x 1 root root  42 Apr 24 20:08 apt
drwxr-xr-x 1 root root 134 Apr 24 20:08 dpkg
drwxr-xr-x 2 root root   6 Apr 24  2018 misc
drwx------ 4 1337 root 208 May 12 16:02 mysql
drwxr-xr-x 2 root root 106 Apr  3 17:14 pam
drwxr-xr-x 1 root root  40 Apr  3 17:12 systemd

I have no name!@82e83d67928a:/var/lib$ ls -al mysql
total 141076
drwx------ 4 1337 root      208 May 12 16:02 .
drwxr-xr-x 1 root root       57 Apr 24 20:08 ..
-rw-rw---- 1 1337 root 18620416 May 12 16:02 aria_log.00000001
-rw-rw---- 1 1337 root       52 May 12 16:02 aria_log_control
-rw-rw---- 1 1337 root      976 May 12 16:02 ib_buffer_pool
-rw-rw---- 1 1337 root 50331648 May 12 16:02 ib_logfile0
-rw-rw---- 1 1337 root 50331648 May 12 16:02 ib_logfile1
-rw-rw---- 1 1337 root 12582912 May 12 16:02 ibdata1
-rw-rw---- 1 1337 root 12582912 May 12 16:02 ibtmp1
-rw-rw---- 1 1337 root        0 May 12 16:02 multi-master.info
drwx------ 2 1337 root     4096 May 12 16:02 mysql
drwx------ 2 1337 root       20 May 12 16:02 performance_schema

I have no name!@82e83d67928a:/var/lib/mysql$ mysql -Uroot -ptest
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.4.12-MariaDB-1:10.4.12+maria~bionic mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

@lingxiankong
Copy link
Author

Thanks @wglambert, I tried again by following your commands, it works! Thanks for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Development

No branches or pull requests

2 participants