1.首先安装docker,尽量用最新版本,如果无法安装新版本docker,请参考这篇:https://142132.com/?id=260
在Centos中,使用脚本直接安装Docker
## 确保 yum 包更新到最新。 sudo yum -y update ## 卸载旧版本 sudo yum remove docker docker-common docker-selinux docker-engine <!-- more --> ## 安装需要的软件包 sudo yum install -y yum-utils device-mapper-persistent-data lvm2 ## 安装container-selinux yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-1.el7_6.noarch.rpm ## 设置yum源 sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo ## 安装 sudo yum -y install docker-ce ## 设置开机启动 sudo systemctl enable docker ## 启动docker sudo systemctl start docker ## 显示版本 docker version
2.安装docker-compose
yum -y install docker-compose
3.创建yml文件和环境配置文件
在适当的目录中,创建docker-compose.yml文件,比如/data/owncloud/docker-compose.yml文件内容:
version: "3" volumes: files: driver: local mysql: driver: local redis: driver: local services: owncloud: image: owncloud/server:${OWNCLOUD_VERSION} container_name: owncloud_server restart: always ports: - ${HTTP_PORT}:8080 depends_on: - mariadb - redis environment: - OWNCLOUD_DOMAIN=${OWNCLOUD_DOMAIN} - OWNCLOUD_TRUSTED_DOMAINS=${OWNCLOUD_TRUSTED_DOMAINS} - OWNCLOUD_DB_TYPE=mysql - OWNCLOUD_DB_NAME=owncloud - OWNCLOUD_DB_USERNAME=owncloud - OWNCLOUD_DB_PASSWORD=owncloud - OWNCLOUD_DB_HOST=mariadb - OWNCLOUD_ADMIN_USERNAME=${ADMIN_USERNAME} - OWNCLOUD_ADMIN_PASSWORD=${ADMIN_PASSWORD} - OWNCLOUD_MYSQL_UTF8MB4=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 mariadb: image: mariadb:10.11.3 # minimum required ownCloud version is 10.9 container_name: owncloud_mariadb restart: always environment: - MYSQL_ROOT_PASSWORD=owncloud - MYSQL_USER=owncloud - MYSQL_PASSWORD=owncloud - MYSQL_DATABASE=owncloud - MARIADB_AUTO_UPGRADE=1 command: ["--max-allowed-packet=128M", "--innodb-log-file-size=64M"] healthcheck: test: ["CMD", "mysqladmin", "ping", "-u", "root", "--password=owncloud"] interval: 10s timeout: 5s retries: 5 volumes: - mysql:/var/lib/mysql redis: image: redis:6 container_name: owncloud_redis restart: always command: ["--databases", "1"] healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 10s timeout: 5s retries: 5 volumes: - redis:/data
在/data/owncloud/下创建一个配置文件.env,内容如下:
OWNCLOUD_VERSION=10.10 OWNCLOUD_DOMAIN=外网服务器IP:8080 ADMIN_USERNAME=管理员账号 ADMIN_PASSWORD=管理员密码 HTTP_PORT=8080
4.构建并且启动容器
docker-compose up -d
然后通过docker-compose ps查看启动状况
启动后要修改一下信任域名
find / -name config.php | grep config/config.php vim /var/lib/docker/volumes/owncloud_files/_data/config/config.php
修改完成之后,就可以启动了,用上面的管理员账号和密码登录。
5.设置里面挂载一下外部存储
6.下载一个owncloud客户端windows版,登录后,新增一个同步文件夹,比如D盘
去掉勾选:使用虚拟文件而不是立即下载内容
最后点下一步就可以开始同步了