当前位置:   article > 正文

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

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

配置文件

切换root权限,新建一个nextcloud的文件夹,进入该目录,创建docker-compose.yml

[cps@localhost ~]$ su root
Password: 666666
[root@localhost cps]# ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
[root@localhost cps]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   latest    d2c94e258dcb   13 months ago   13.3kB
centos        7         eeb6ee3f44bd   2 years ago     204MB
[root@localhost cps]# pwd
/home/cps
[root@localhost cps]# mkdir nextcloud
[root@localhost cps]# cd nextcloud/
[root@localhost nextcloud]# touch docker-compose.yml
[root@localhost nextcloud]# gedit docker-compose.yml 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

安装部署

docker-compose up -d
  • 1

本地访问

http:localhost:8008
在这里插入图片描述

Nextcloud设置

在这里插入图片描述
等待一会
在这里插入图片描述

内网穿透

cpolar安装

curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
sudo systemctl enable cpolar
sudo systemctl start cpolar
  • 1
  • 2
  • 3

cpolar登录web

  1. https://www.cpolar.com/官网注册账号
  2. cpolar安装成功后,在外部浏览器上访问Linux 的9200端口即:【http://服务器的局域网ip:9200】
  3. 使用cpolar账号登录,登录后即可看到cpolar web 配置界面,在仪表盘下创建隧道。

在这里插入图片描述

配置可信任域名

在这里插入图片描述

‘trusted_domains’ => 添加可信任域名5256185a.r1.vip.cpolar.cn

[root@localhost nextcloud]# find / -name "config.php"
find: ‘/run/user/1001/gvfs’: Permission denied
/var/lib/docker/volumes/ad49ff6c8750b8ec4841ac640f8c6b1a4f49fece3a97401bd714d072e1cedda3/_data/config/config.php
[root@localhost nextcloud]# gedit /var/lib/docker/volumes/ad49ff6c8750b8ec4841ac640f8c6b1a4f49fece3a97401bd714d072e1cedda3/_data/config/config.php
[root@localhost nextcloud]# 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,
);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45

确保docker容器NextCloud、Mysql已开启

[root@localhost nextcloud]# 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
  • 1
  • 2
  • 3
  • 4

公网访问

在这里插入图片描述

问题与解决

bash: docker-compose: command not found…

[root@localhost nextcloud]# docker-compose up -d
bash: docker-compose: command not found...
  • 1
  • 2
  1. 安装工具源

sudo yum -y install epel-release

  1. docker-compose依赖python,安装 python-pip 模块

sudo yum install python-pip

  1. 下载docker-compose 安装包

wget https://github.com/docker/compose/releases/download/1.14.0-rc2/docker-compose-Linux-x86_64

  1. 重命名工具 docker-compose 名称,并移动到系统可执行目录

mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose

  1. 修改文件的可执行属性

chmod +x /usr/local/bin/docker-compose

  1. 验证

docker-compose -version


mysql 很多Waiting。。。镜像pull不下来

在这里插入图片描述

  1. 配置文件
 vi   /etc/docker/daemon.json
  • 1
{ 
 "registry-mirrors": ["https://studk.mirror.aliyuncs.com","http://f1361db2.m.daocloud.io"] 
} 
  • 1
  • 2
  • 3
  1. 重启服务
sudo systemctl restart docker
  • 1

通过不被信任的域名访问

在这里插入图片描述

'trusted_domains' =>
  array (
   0 => 'localhost',
   1 => '这里写域名',
),
  • 1
  • 2
  • 3
  • 4
  • 5

参考

我的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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/719100
推荐阅读
相关标签
  

闽ICP备14008679号