docker-compose安装nextcloud
docker-compose搭建nextcloud
前置条件
- 安装docker
docker-compose配置文件
version: '3.5'
services:
db_nextcloud:
container_name: db_nextcloud
image: mariadb
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
networks:
cloudnetwork:
ipv4_address: 172.18.0.5
volumes:
- "./db:/var/lib/mysql" #./db是数据库持久化目录,可以修改
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: nextcloud!@
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
MYSQL_PASSWORD: nextcloud!@
restart: always
nextcloud:
container_name: nextcloud
image: nextcloud
networks:
cloudnetwork:
ports:
- 8061:80
- 4433:443
depends_on:
- db_nextcloud
volumes:
- "./data:/var/www/html" #./data是数据位置,可以修改
restart: always
networks:
cloudnetwork:
ipam:
config:
- subnet: 172.18.0.0/16
gateway: 172.18.0.1
安装
# 创建nextcloud目录
mkdir /nextcloud
# 将上面yml文件复制到/nextcloud
cp docker-compose-nextcloud.yml /nextcloud
# 安装
docker-compose -f docker-compose-nextcloud.yml up -d
注意:如果有安装其他软件,网段改为不一样的,同时清理网络
修改mariadb配置
# 进入容器mariadb
docker exec -it db_nextcloud /bin/bash
# mysql登录
mysql -u root -p
set global innodb_read_only_compressed=off;
验证及配置
配置
机器名为docker容器名及yml中配置的名称
验证
nginx配置域名
upstream nextcloud.bb.cc {
server localhost:8061;
}
server {
listen 80;
server_name nextcloud.bb.cc;
location / {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
#root /kodbox/site/;
#index index.php;
proxy_pass http://nextcloud.bb.cc;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
登录可能报错添加域名到config.php
参考
问题
- 网络问题
docker-compose pool overlaps with other one on this address
解决
docker network prune
同时更换网段
172.19.0.0 (自定义)
- 数据库问题
nextcloud install Error while trying to initialise the database: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 4047 InnoDB refuses to write tables with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE
解决
# 进入容器
docker exec -it db_nextcloud /bin/bash
mysql -u root -p
set global innodb_read_only_compressed=off;
- 使用域名不能访问
添加域名修改配置文件
config.php
# 添加
'trusted_domains' =>
array (
0 => 'nextcloud.bb.cc',
)
使用注意
- 安装了markdown Editor,md文件不能阅读只能下载,检查Text是否被禁用了,建议下载 plain text
应用->禁用Text,下载plain text