Docker: Can't create or write into the data directory

Server: CentOS 7
Docker: 1.13.1
Nextcloud: 13.0
Nextcloud’s Docker image : https://github.com/nextcloud/docker

I successfully installed Nextcloud 13.0 using Docker and Docker Compose.

By default, my Nextcloud installation stores data to the following path:

/var/lib/docker/volumes/nextcloud_nextcloud/_data/data/user/files

My /var folder is located on a small partition while /home folder has about 2Tb of storage space. I’m trying to setup Nextcloud to store uploaded files to /home/iamdocker/nextcloud/data on the host machine but it doesn’t work.

The Nextcloud configuration page displays the following message :

Error
Can’t create or write into the data directory /home/iamdocker/nextcloud/data/

.env

MYSQL_ROOT_PASSWORD=***********************
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud
MYSQL_PASSWORD=************************************
MYSQL_HOST=db

NEXTCLOUD_VERSION=13.0
NEXTCLOUD_ADMIN_USER=example
NEXTCLOUD_ADMIN_PASSWORD=********************************
NEXTCLOUD_TABLE_PREFIX=nc_
NEXTCLOUD_DATA_DIR=/home/iamdocker/nextcloud/data/

docker-compose.yml

version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb
    env_file:
      - .env
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=${MYSQL_DATABASE}
      - MYSQL_USER=${MYSQL_USER}
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}

  app:
    image: nextcloud:${NEXTCLOUD_VERSION}
    env_file:
      - .env
    ports:
      - 8081:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
    environment:
      - NEXTCLOUD_ADMIN_USER=${NEXTCLOUD_ADMIN_USER}
      - NEXTCLOUD_ADMIN_PASSWORD=${NEXTCLOUD_ADMIN_PASSWORD}
      - NEXTCLOUD_TABLE_PREFIX=${NEXTCLOUD_TABLE_PREFIX}
      - NEXTCLOUD_DATA_DIR=${NEXTCLOUD_DATA_DIR}
    restart: always

Thank you!

i have this same issue, changed it to /var/www/html/data and now / gets filled instead of the actual external email.
i only get about 50GB of space on the / folder.

im not sure what im doing wrong, but i cant have only 50GB of storage when im having close to 400GB of data.