温锦文欧普厨电及净水器总代理 发表于 2024-7-12 20:59:55

【云盘算】Docker部署Nextcloud网盘并实现随地公网远程访问

配置文件

切换root权限,新建一个nextcloud的文件夹,进入该目录,创建docker-compose.yml
$ su root
Password: 666666
# ls
DesktopDocumentsDownloadsMusicPicturesPublicTemplatesVideos
# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   latest    d2c94e258dcb   13 months ago   13.3kB
centos      7         eeb6ee3f44bd   2 years ago   204MB
# pwd
/home/cps
# mkdir nextcloud
# cd nextcloud/
# touch docker-compose.yml
# gedit docker-compose.yml

version: '2.1'

volumes:
nextcloud:
db:

services:
db:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    volumes:
      - /home/cps/nextcloud/mysql:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=12345678
      - MYSQL_PASSWORD=nextcloud
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
   
app:
    image: nextcloud
    ports:
      - 8008:80
    links:
      - db
    volumes:
      - /home/cps/nextcloud/nextcloud:/var/www/html

安装部署

docker-compose up -d
本地访问

http:localhost:8008
https://img-blog.csdnimg.cn/direct/ed34628312734c1c88324f0edd1cf2d6.png#pic_center
Nextcloud设置

https://img-blog.csdnimg.cn/direct/b2e386c20665496297b47700cdcd1560.png#pic_center
等候一会
https://img-blog.csdnimg.cn/direct/a55b0a8da7b14f98a7f4a10fd5529384.png#pic_center
内网穿透

cpolar安装

curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
sudo systemctl enable cpolar
sudo systemctl start cpolar
cpolar登录web

   
[*]https://www.cpolar.com/官网注册账号
[*]cpolar安装成功后,在外部浏览器上访问Linux 的9200端口即:【http://服务器的局域网ip:9200】
[*]使用cpolar账号登录,登录后即可看到cpolar web 配置界面,在仪表盘下创建隧道。
https://img-blog.csdnimg.cn/direct/8ca4633effac4c8d9d01a8efef55ee71.png
配置可信任域名

https://img-blog.csdnimg.cn/direct/522065d92edf4d71843a7d23ad0dfbbb.png
‘trusted_domains’ => 添加可信任域名5256185a.r1.vip.cpolar.cn
# find / -name "config.php"
find: ‘/run/user/1001/gvfs’: Permission denied
/var/lib/docker/volumes/ad49ff6c8750b8ec4841ac640f8c6b1a4f49fece3a97401bd714d072e1cedda3/_data/config/config.php
# gedit /var/lib/docker/volumes/ad49ff6c8750b8ec4841ac640f8c6b1a4f49fece3a97401bd714d072e1cedda3/_data/config/config.php
# cat /var/lib/docker/volumes/ad49ff6c8750b8ec4841ac640f8c6b1a4f49fece3a97401bd714d072e1cedda3/_data/config/config.php
<?php
$CONFIG = array (
'htaccess.RewriteBase' => '/',
'memcache.local' => '\\OC\\Memcache\\APCu',
'apps_paths' =>
array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
),
'instanceid' => 'ocq23pxvlmom',
'passwordsalt' => 'uzZUljuHVuZ8MtsoKF6pljCMUskNwo',
'secret' => 'hevqvGaITGj/9zns/PpMJZ2L98xCpl0g6iS76aeB9/1siZpZ',
'trusted_domains' =>
array (
    0 => 'localhost:8008',
    1 => '5256185a.r1.vip.cpolar.cn',
),
'datadirectory' => '/var/www/html/data',
'dbtype' => 'mysql',
'version' => '23.0.0.10',
'overwrite.cli.url' => 'http://localhost:8008',
'dbname' => 'nextcloud',
'dbhost' => 'db',
'dbport' => '',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'nextcloud',
'dbpassword' => 'nextcloud',
'installed' => true,
);
确保docker容器NextCloud、Mysql已开启
# docker ps
CONTAINER ID   IMAGE       COMMAND                  CREATED      STATUS      PORTS                                 NAMES
1e9178afddf5   nextcloud   "/entrypoint.sh apac…"   2 days ago   Up 2 days   0.0.0.0:8008->80/tcp, :::8008->80/tcp   nextcloud_app_1
e504c967c5b5   mysql       "docker-entrypoint.s…"   2 days ago   Up 2 days   3306/tcp, 33060/tcp                     nextcloud_db_1
公网访问

https://img-blog.csdnimg.cn/direct/87a347f22086401c9f7a407de1c56aa3.png
问题与解决

bash: docker-compose: command not found…

# docker-compose up -d
bash: docker-compose: command not found...
[*]安装工具源
   sudo yum -y install epel-release

[*]docker-compose依赖python,安装 python-pip 模块
   sudo yum install python-pip

[*]下载docker-compose 安装包
   wget https://github.com/docker/compose/releases/download/1.14.0-rc2/docker-compose-Linux-x86_64

[*]重命名工具 docker-compose 名称,并移动到系统可实行目录
   mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose

[*]修改文件的可实行属性
   chmod +x /usr/local/bin/docker-compose

[*]验证
   docker-compose -version
mysql 很多Waiting。。。镜像pull不下来

https://img-blog.csdnimg.cn/direct/ddf4bea074884dcea8f2e8a12b79ab65.png

[*]配置文件
vi   /etc/docker/daemon.json
{
"registry-mirrors": ["https://studk.mirror.aliyuncs.com","http://f1361db2.m.daocloud.io"]
}

[*]重启服务
sudo systemctl restart docker
通过不被信任的域名访问

https://img-blog.csdnimg.cn/direct/77b1b6faeee9427f98fad71089d5d3cc.png
'trusted_domains' =>
array (
   0 => 'localhost',
   1 => '这里写域名',
),
参考

我的docker漫笔19:Nextcloud部署
https://juejin.cn/post/6982782635546411015
docker-compose: command not found问题的两种常用方法
https://blog.csdn.net/sinat_17358633/article/details/128764036
容器技能.合版.v0.095.增改.学生版.pdf 【3.3.2 镜像加快】
docker镜像pull不下来终极解决方法
https://www.cnblogs.com/wang50902/p/11378202.html
Docker 配置国内源加快(2023/05/14)
https://blog.csdn.net/qq_44797987/article/details/112681224
docker 报错ERROR: client version 1.22 is too old. Minimum supported API version is 1.24···
https://blog.csdn.net/zwy3327078581/article/details/136037950
如安在Linux系统使用Docker部署Nextcloud网盘并实现随地公网远程访问
https://cloud.tencent.com/developer/article/2392880
Nextcloud通过不被信任的域名访问解决方法 Nextcloud 您正在访问来自不信任域名的服务器
https://blog.51cto.com/u_15296600/3008162

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 【云盘算】Docker部署Nextcloud网盘并实现随地公网远程访问