mineshaftgap / d4m-nfs

Docker for Mac with NFS for performance improvements over osxfs
296 stars 26 forks source link

Are mounts read-only? #22

Closed cytopia closed 7 years ago

cytopia commented 7 years ago

All my docker container say they cannot write. I have simply ./d4m-nfs.sh without any config.

Are the mounts read-only by default and if so, how to change that?

if-kyle commented 7 years ago

Hello @cytopia,

No the mounts are not read only.

please provide the following:

screenshot of Docker for Mac's Preferences -> File Sharing attachment of d4m-nfs/etc/d4m-nfs-mounts.txt attachment of /tmp/d4m-mount-nfs.sh attachment of /tmp/d4m-nfs-mounts.txt attachment of /etc/exports

cytopia commented 7 years ago

Repo

$ git log
commit 4ac858fe286bbe4e21d28e4801d8ed602eada301
Author: Kenn Herman <kenn@ifsight.com>
Date:   Mon Nov 28 19:08:57 2016 -0800

    cleaner output (with [d4m-nfs] prefix), better cache management, shorter sleeps, rm legacy cache dir, wait until setup is complete-screen was dumping out and mac going on without it

Configs

Docker Preferences -> File Sharing

/tmp

d4m-nfs/etc/d4m-nfs-mounts.txt (does not exist)

$ ls -a etc/
.gitignore

tmp/d4m-mount-nfs.sh

$ cat /tmp/d4m-mount-nfs.sh
ln -ns /tmp/d4m-apk-cache /etc/apk/cache
apk update
apk add nfs-utils sntpc
rpcbind -s

DEFGW=$(ip route|awk '/default/{print $3}')
FSTAB="\n\n# d4m-nfs mounts\n"

if ! $(grep ':/mnt' /tmp/d4m-nfs-mounts.txt > /dev/null 2>&1); then
  mkdir -p /mnt
  FSTAB="${FSTAB}${DEFGW}:/Users/cytopia /mnt nfs nolock,local_lock=all 0 0"
fi

if [ -e /tmp/d4m-nfs-mounts.txt ]; then
  while read MOUNT; do
    DSTDIR=$(echo "$MOUNT" | cut -d: -f2)
    mkdir -p ${DSTDIR}
    FSTAB="${FSTAB}\n${DEFGW}:$(echo "$MOUNT" | cut -d: -f1) ${DSTDIR} nfs nolock,local_lock=all 0 0"
  done < /tmp/d4m-nfs-mounts.txt
fi

echo -e $FSTAB >> /etc/fstab

sntpc -i 10 ${DEFGW} &

sleep .5
mount -a
touch /tmp/d4m-done

/tmp/d4m-nfs-mounts.txt

$  cat /tmp/d4m-nfs-mounts.txt
/Users/cytopia:/mnt

/etc/exports

$ cat /etc/exports
# d4m-nfs exports

"/Users/cytopia" -alldirs -mapall=595520278:1286676289 localhost

/etc/fstab (empty)

$ cat /etc/fstab

Attaching screen and trying to create files

$ screen -r d4m
$ cd /mnt
$ touch t
touch: t: Read-only file system

Starting docker from OSX

$ cd devilbox
$ docker-compose-up
...
php_1       | Creating mailbox file: File exists
php_1       | root $ chmod 664 /var/mail/mailtrap
php_1       | chmod: changing permissions of '/var/mail/mailtrap': Read-only file system
devilbox_mysql_1 exited with code 1
devilbox_php_1 exited with code 1
httpd_1     | nginx: [emerg] open() "/var/log/nginx-stable/access.log" failed (30: Read-only file system)
devilbox_httpd_1 exited with code 1
cytopia commented 7 years ago

I got a bit further now. Sometimes it works and sometimes they are marked as read-only.

When I come to a working state, where /mnt is writeable, i get another error about chowning stuff.

I use standard postgres docker which wants to create a database and then chown some directories. Unfortunately it exits

postgres_1  | chown: changing ownership of ‘/var/lib/postgresql/data/pgdata’: Operation not permitted

Any restrictions on nfs mounts that chown from within a docker is prohibited? Or any other rights I can set on the nfs mounts?

cytopia commented 7 years ago

It seems to work, when I manually edit /etc/exports and use root:wheel mapping

"/Users/cytopia" -alldirs -mapall=root:wheel localhost

Can this be done permanently somehow?

if-kyle commented 7 years ago

We have run into issues with mysql and perms and sometimes starting the stack just fails, and then restarting it right after it will some times work.

While note ideal, you might try a chmod -R 777 of your postgre folder on your mac and see if that solves the issue.

if-kenn commented 7 years ago

@cytopia are you happen to be using LDAP or something? 595520278:1286676289 looks incredible suspect.

We have not tried to use with any kind of directory services authentication system. On most typical Mac setups that would either be 501:20 or 0:0. You might want to explicitly change it to 0:0 so it is mounted as root in the container, that is the same as your root:wheel. If you want it to be permanent, please use d4m-nfs/etc/d4m-nfs-mounts.txt.

if-kyle commented 7 years ago

closing due to inactivity