环境
- debian 9
- docker
- docker-compose
- nextcloud image
- mariadb image
docker-ce与docker-compose安装
sudo apt-get update #安装Docker依赖 sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg2 \ software-properties-common #增加官方GPG密钥 curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - #增加Docker-ce仓库 sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/debian \ $(lsb_release -cs) \ stable" #从仓库安装Docker-CE sudo apt-get update && apt-get install -y docker-ce #启动Docker sudo systemctl start docker #设置Docker开机启动 sudo systemctl enable docker # 安装 python3 python3-pip sudo apt install -y python3 python3-pip # 安装 docker-compose sudo pip3 install docker-compose
编写 docker-compose.yml
version: '2' services: db: image: mariadb restart: always volumes: - /home/data/nextcloud/db:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=root - MYSQL_PASSWORD=nextcloud - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud app: image: nextcloud restart: always ports: - 4567:80 links: - db volumes: - /home/data/nextcloud/www:/var/www/html
启动容器
# 启动容器 sudo docker-compose up -d # 更新nextcloud sudo docker pull nextcloud sudo docker-compose down && sudo docker-compose up -d
caddy反向代理
https://xxx.xxxx.xxx{ root /usr/local/caddy/www/file timeouts none tls abc@gmail.com gzip proxy / 127.0.0.1:4567 { transparent } }
nextcloud初始化配置
浏览器键入https://xxx.xxxx.xxx进行初始化配置,设置管理员密码,并且在MySQL/MariaDB 配置中填写数据库名字,数据库用户名及密码,与docker-compose.yml一致