我跟随this guide在我的VPS上安装了owncloud服务器,它可以正常工作。但是,当我尝试将文件卷挂载到主机服务器时出现问题。以下是我使用的docker-compose.yml
文件。如果我直接使用yml文件运行docker映像,即使我手动创建了/mnt/data
,我的VPS目录/mnt/data
下也找不到任何owncloud数据。
version: '2.1'
volumes:
files:
driver: local
mysql:
driver: local
backup:
driver: local
redis:
driver: local
services:
owncloud:
image: owncloud/server:${OWNCLOUD_VERSION}
restart: always
ports:
- ${HTTPS_PORT}:443
- ${HTTP_PORT}:80
depends_on:
- db
- redis
environment:
- OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN}
- OWNCLOUD_DB_TYPE=mysql
- OWNCLOUD_DB_NAME=owncloud
- OWNCLOUD_DB_USERNAME=owncloud
- OWNCLOUD_DB_PASSWORD=owncloud
- OWNCLOUD_DB_HOST=db
- OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME}
- OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD}
- OWNCLOUD_UTF8MB4_ENABLED=true
- OWNCLOUD_REDIS_ENABLED=true
- OWNCLOUD_REDIS_HOST=redis
healthcheck:
test: ["CMD", "/usr/bin/healthcheck"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- files:/mnt/data
db:
image: webhippie/mariadb:latest
restart: always
environment:
- MARIADB_ROOT_PASSWORD=owncloud
- MARIADB_USERNAME=owncloud
- MARIADB_PASSWORD=owncloud
- MARIADB_DATABASE=owncloud
- MARIADB_MAX_ALLOWED_PACKET=128M
- MARIADB_INNODB_LOG_FILE_SIZE=64M
- MARIADB_INNODB_LARGE_PREFIX=ON
- MARIADB_INNODB_FILE_FORMAT=Barracuda
healthcheck:
test: ["CMD", "/usr/bin/healthcheck"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- mysql:/var/lib/mysql
- backup:/var/lib/backup
redis:
image: webhippie/redis:latest
restart: always
environment:
- REDIS_DATABASES=1
healthcheck:
test: ["CMD", "/usr/bin/healthcheck"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- redis:/var/lib/redis
因此,我尝试将files:/mnt/data
行修改为files:/mnt/data:/mnt/data
,然后提示以下错误。
ERROR: for ownclouddockerserver_owncloud_1 Cannot create container for service owncloud: invalid bind mount spec "ownclouddockerserver_files:/mnt/data:/mnt/data": invalid mode: /mnt/data
ERROR: for owncloud Cannot create container for service owncloud: invalid bind mount spec "ownclouddockerserver_files:/mnt/data:/mnt/data": invalid mode: /mnt/data
有人可以帮助我找出将外部目录挂载到容器的正确方法吗?非常感激。