Skip to content

mysql:5.5: can't chown on nfs mount #153

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
pebbe opened this issue Mar 25, 2016 · 8 comments
Closed

mysql:5.5: can't chown on nfs mount #153

pebbe opened this issue Mar 25, 2016 · 8 comments

Comments

@pebbe
Copy link

pebbe commented Mar 25, 2016

Running mysql:5.5 with /var/lib/mysql mounted on a nfs file system, I get this error:

chown: changing ownership of '/var/lib/mysql/': Invalid argument

I edited the entrypoint script to see if I had write access in /var/lib/mysql, and I have, and files I create in the entrypoint script are created in the mounted directory. It's just the chown that fails, and at that point, the script fails.

It works fine on an ext4 file system on the same machine, and then the result of chown is 999:localadmin

@pebbe
Copy link
Author

pebbe commented Mar 25, 2016

It seems inside Docker, I only have write access in the directory if I give it permission 777 outside Docker. chmod still fails.

@yosifkit
Copy link
Member

What if we wrap the chown in an if statement to check the permissions?

# the simlest way is to be the user and check if they can write
# but that means we would need gosu to change users
if ! gosu mysql bash -c "test -w '$DATADIR'"; then
    chown -R mysql:mysql "$DATADIR"
fi

What do you think @ltangvald?

@ltangvald
Copy link
Collaborator

I guess it could potentially fail if $DATADIR is writeable but, say, $DATADIR/mysql isn't, but I don't really see any reasonable cases where that would be the case, so I think it looks good :)

@tianon
Copy link
Member

tianon commented Apr 4, 2016

Another option would be something like what we've done in several other images, allowing for docker run --user ... to work (I've done some very positive preliminary testing with this idea and MySQL handles it pretty well, only throwing a warning about how it can only apply a user configuration block if it's run as root): https://github.com/docker-library/mongo/pull/81/files, https://github.com/docker-library/redis/pull/48/files, https://github.com/docker-library/cassandra/pull/48/files

This way, folks who wanted to skip the chown could use --user mysql or even --user 1000:1000 or whatever they'd like (matching the permissions on whatever storage they've got), but existing users who do want Docker/the image to take care of permissions would be unaffected. Thoughts?

@shantanuo
Copy link

I do completely agree with what @tianon has said about allowing --user variable.

@ltangvald
Copy link
Collaborator

Yeah, I think that sounds pretty good

@pebbe
Copy link
Author

pebbe commented May 15, 2016

After docker pull mysql:5.5 I still get the same problem.

Without --user:

docker run \
    -i -t --rm \
    -v /net/aistaff/kleiweg/tmp/paqudata/mysql:/var/lib/mysql \
    -e MYSQL_ROOT_PASSWORD=root \
    -e MYSQL_DATABASE=paqu \
    -e MYSQL_USER=paqu \
    -e MYSQL_PASSWORD=paqu \
    mysql:5.5

Output:

chown: cannot read directory '/var/lib/mysql/performance_schema': Permission denied
chown: changing ownership of '/var/lib/mysql/ibdata1': Invalid argument
chown: cannot read directory '/var/lib/mysql/paqu': Permission denied
chown: changing ownership of '/var/lib/mysql/ib_logfile0': Invalid argument
chown: cannot read directory '/var/lib/mysql/mysql': Permission denied
chown: changing ownership of '/var/lib/mysql/ib_logfile1': Invalid argument
chown: changing ownership of '/var/lib/mysql/': Invalid argument

With --user:

docker run \
    -i -t --rm \
    --user=10209327:300001 \
    -v /net/aistaff/kleiweg/tmp/paqudata/mysql:/var/lib/mysql \
    -e MYSQL_ROOT_PASSWORD=root \
    -e MYSQL_DATABASE=paqu \
    -e MYSQL_USER=paqu \
    -e MYSQL_PASSWORD=paqu \
    mysql:5.5

Ouput:

chown: changing ownership of '/var/lib/mysql/performance_schema/events_waits_summary_global_by_event_name.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/file_summary_by_event_name.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/setup_timers.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/rwlock_instances.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/events_waits_current.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/events_waits_history_long.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/events_waits_history.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/threads.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/file_summary_by_instance.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/setup_consumers.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/events_waits_summary_by_thread_by_event_name.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/mutex_instances.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/events_waits_summary_by_instance.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/file_instances.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/db.opt': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/cond_instances.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/performance_timers.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema/setup_instruments.frm': Invalid argument
chown: changing ownership of '/var/lib/mysql/performance_schema': Invalid argument
chown: changing ownership of '/var/lib/mysql/ibdata1': Invalid argument
chown: changing ownership of '/var/lib/mysql/paqu/pq_c_lassysmall_deprel.frm': Invalid argument
... (many more)

More info:

$ ls -nla /net/aistaff/kleiweg/tmp/paqudata/mysql
totaal 503832
drwxr-xr-x 5 10209327 300001      4096 mei 15 14:09 .
drwxr-xr-x 6 10209327 300001      4096 mei 14 13:47 ..
-rw-rw---- 1 10209327 300001   5242880 mei 14 13:49 ib_logfile0
-rw-rw---- 1 10209327 300001   5242880 mei 14 13:47 ib_logfile1
-rw-rw---- 1 10209327 300001 505413632 mei 14 13:49 ibdata1
drwx------ 2 10209327 300001      4096 mei 14 13:21 mysql
drwx------ 2 10209327 300001      4096 mei 14 13:40 paqu
drwx------ 2 10209327 300001      4096 mei 14 13:21 performance_schema

The solution would be that chown should not be used, but instead, userID en goupID of mysql should be changed to match those of the values of --user or those of the existing directory. Something like...

usermod -o -u `stat -c %u /var/lib/mysql` mysql
groupmod -o -g `stat -c %g /var/lib/mysql` mysql
chown -R mysql:root /var/run/mysqld/

@tianon
Copy link
Member

tianon commented May 16, 2016

That change isn't published to the Hub just yet; see docker-library/official-images#1740

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants