greyltc / docker-owncloud

Arch linux based docker container with owncloud
111 stars 37 forks source link

Could not write to Data directory #104

Closed Moep90 closed 7 years ago

Moep90 commented 7 years ago

Hello,

I setup Owncloud with MySQL while using docker-compose. As I pulled your image and run it with compose, during the setup it told me that the data directory inside the container is not writable.

# outside the container
sudo docker exec -it <CTID> bash

# inside the container
$ ll /usr/share/webapps/owncloud/
[...]
drwxr-xr-x  2 root root 4.0K Sep 20 21:59 data
[...]

So i manually changed it to root:http and chmod it to 770

# Changes which need to be tone inside the container
chown -R root:http /usr/share/webapps/owncloud/data
chmod 770 /usr/share/webapps/owncloud/data

$ ll /usr/share/webapps/owncloud/
[...]
drwxrwxr-x  3 root http 4.0K Sep 20 22:17 data
[...]

after that, its working properly.

greyltc commented 7 years ago

Are you using my container?

Because my container does not seem to have that problem:

$ docker run l3iggs/owncloud ls -al /usr/share/webapps/owncloud/
total 140
drwxr-x--- 1 root http   458 Aug 21 17:18 .
drwxr-xr-x 1 root root    32 Aug 21 17:18 ..
-rw-rw-r-- 1 root http  2496 Jul 20 09:15 .htaccess
-rw-rw-r-- 1 root http   163 Jul 20 09:15 .user.ini
drwxr-x--- 1 root http   588 Aug 21 17:18 3rdparty
-rw-r----- 1 root http  8301 Jul 20 09:15 AUTHORS
-rw-r----- 1 root http 34520 Jul 20 09:15 COPYING-AGPL
drwxr-x--- 1 http http   608 Jul 20 09:15 apps
drwxr-x--- 1 http http     0 Aug 21 17:18 assets
drwxr-x--- 1 http http    72 Aug 21 17:19 config
-rw-r----- 1 root http  3805 Jul 20 09:15 console.php
drwxr-x--- 1 root http   332 Aug 21 17:18 core
-rw-r----- 1 root http  5032 Jul 20 09:15 cron.php
drwxr-x--- 1 http http     0 Aug 21 17:18 data
-rw-r----- 1 root http 35830 Jul 20 09:15 db_structure.xml
-rw-r----- 1 root http   179 Jul 20 09:15 index.html
-rw-r----- 1 root http  2282 Jul 20 09:15 index.php
drwxr-x--- 1 root http    58 Aug 21 17:18 l10n
drwxr-x--- 1 root http    94 Aug 21 17:18 lib
-rwxr-x--x 1 root http   283 Jul 20 09:15 occ
drwxr-x--- 1 root http    70 Aug 21 17:18 ocs
drwxr-x--- 1 root http    18 Aug 21 17:18 ocs-provider
-rw-r----- 1 root http  3086 Jul 20 09:15 public.php
-rw-r----- 1 root http  5428 Jul 20 09:15 remote.php
drwxr-x--- 1 root http    34 Jul 20 09:15 resources
-rw-r----- 1 root http    26 Jul 20 09:15 robots.txt
drwxr-x--- 1 root http   288 Aug 21 17:18 settings
-rw-r----- 1 root http  1893 Jul 20 09:15 status.php
drwxr-x--- 1 http http    26 Aug 21 17:18 themes
drwxr-x--- 1 http http   310 Aug 21 17:18 updater
-rw-r----- 1 root http   234 Jul 20 09:15 version.php
Moep90 commented 7 years ago

Hello,

yes I do.

# docker-compose file for MySQL
owncloud:
  image: l3iggs/owncloud
  restart: always
  ports:
    - "11080:80"
    - "11443:443"
  links:
    - mysql
  environment:
    VIRTUAL_HOST: ...
    START_MYSQL: 'false'
    TARGET_SUBDIR: /
    #DO_SSL_SELF_GENERATION: true
    #SUBJECT: /C=XX/L=CITY/O=ORGANIZATION/OU=UNIT/CN=localhost
    # requires proper authorizations, see rights.sh
    # https://github.com/l3iggs/docker-owncloud/wiki/Store-your-data-outside-of-the-container
  volumes:
    - ./owncloud/data:/usr/share/webapps/owncloud/data
    - ./owncloud/config:/etc/webapps/owncloud/config

mysql:
  # https://registry.hub.docker.com/_/mysql/
  image: mysql:latest
  restart: always
  mem_limit: 1024m
  expose:
     - "3306"
  environment:
    MYSQL_DATABASE: owncloud
    MYSQL_ROOT_PASSWORD: ...
    MYSQL_USER: owncloud
    MYSQL_PASSWORD: ...
  volumes:
    - ./mysql/var/lib/mysql:/var/lib/mysql
    - ./mysql/etc/mysql/conf.d:/etc/mysql/conf.d

  # --skip-name-resolve
  # avoids: ""[Warning] IP address '172.17.0.60' could not be resolved: Name or service not known""
  command: mysqld --skip-name-resolve
greyltc commented 7 years ago

Looks like you've mapped a volume to /usr/share/webapps/owncloud/data that has the wrong permissions. When you do a volume mapping in docker, the permissions (everything, including the UIDs and GIDs) of the original folder you're mapping into the container are retained inside the container.

So I'd say if you were to do a chown -R 33 ./owncloud/data outside the container to fix the ownership of your data folder that you'll be mapping into the container, your problem should be solved.

Moep90 commented 7 years ago

chown -R 33 ./owncloud/data Is unfortunetly not working for me.

After migrating to another server, the permissens not working at all. (MySQL and Owncloud) I dont know which UUID I had before 👎 :-(

greyltc commented 7 years ago

I doubt running chown -R root:http outside the container is a good thing. The UID you just changed to probably doesn't match what the container expects. You could try running the permissions fixing script I have included with the container:

docker exec -it oc sh -c 'set-oc-perms runtime'