docker下nextcloud的安装和升级

安装

安装步骤参照 Rat’s Blog 的文章 使用Docker快速安装NextCloud个人私有云盘

命令如下:

#安装Docker
curl -sSL https://get.docker.com/ | sh
#下载并启动Nextcloud
docker pull greyltc/nextcloud
docker run --name nc -p 80:80 -p 443:443 -d greyltc/nextcloud
#升级程序
docker exec -it nc sh -c 'set-nc-perms upgrade'
#更新权限
docker exec -it nc sh -c 'set-nc-perms runtime'

安装之后,在管理后台的升级界面能看到Current version is 11.0.1
可以升级成12.0.6

升级

The following extra files have been found: assets

在升级页面点击Start update,报错
Check for expected files
The following extra files have been found:
assets

在nextcloud的issue找到有人提问类似的问题10.0.2 update fails: The following extra files have been found

解决办法是找到文件夹assets,并将其删除。

进入docker容器

进入docker容器有多种方式,参照进入docker容器的方法 和 Docker容器进入的4种方式
选择 docker exec 的方式

使用方法:docker exec -it [container name] [command]
适用范围:docker宿主机内部登录容器
优点:快捷方便
缺点:外部终端无法使用这种方法登录容器
使用参数介绍
-i, –interactive Keep STDIN open even if not attached ————交互
-t, –tty Allocate a pseudo-TTY————分配伪终端

#查找正在运行的docker镜像名称和id
$sudo docker ps -a
CONTAINER ID        IMAGE                                                     COMMAND                  CREATED             STATUS              PORTS                                                          NAMES
66ae53f080fc        greyltc/nextcloud                                         "/bin/sh -c 'start-s…"   8 hours ago         Up 8 hours          0.0.0.0:80->80/tcp, 3306/tcp, 0.0.0.0:443->443/tcp, 5432/tcp   nc
#执行docker exec命令进入容器
$ sudo docker exec -i -t 66ae53f080fc /bin/bash
[root@66ae53f080fc /]#

找到assets并删除assets

#找到assets
[root@66ae53f080fc /]# find -name assets
./usr/share/webapps/nextcloud/assets
./usr/share/webapps/nextcloud/3rdparty/sabre/dav/lib/DAV/Browser/assets
#删除assets
[root@66ae53f080fc /]# rm -R /usr/share/webapps/nextcloud/assets/
#验证是否已经删除
[root@66ae53f080fc /]# ls -l /usr/share/webapps/nextcloud/assets/
ls: cannot access '/usr/share/webapps/nextcloud/assets/': No such file or directory

The following places can not be written

点击Retry update,Check for expected files完成,但Check for write permissions仍有报错

The following places can not be written to:
/usr/share/webapps/nextcloud/updater/../index.php

该报错推断是因为文件的权限不足导致,推断参考Write permission issues when updating from 10.0.1 to 10.0.2

查看updater文件夹的权限

[root@66ae53f080fc /]# cd /usr/share/webapps/nextcloud/
[root@66ae53f080fc nextcloud]# ls
3rdparty     core              index.php  ocs-provider  settings
AUTHORS      cron.php          l10n       public.php    status.php
apps         data              lib        remote.php    themes
config       db_structure.xml  occ        resources     updater
console.php  index.html        ocs        robots.txt    version.php
[root@66ae53f080fc nextcloud]# ls -l updater/
total 648
-rw-r----- 1 http http  57353 Jan 15  2017 index.php
-rw-r----- 1 http http 591718 Jan 15  2017 updater.phar
[root@66ae53f080fc nextcloud]# chmod -R 777 updater/
[root@66ae53f080fc nextcloud]# ls -l updater/
total 648
-rwxrwxrwx 1 http http  57353 Jan 15  2017 index.php
-rwxrwxrwx 1 http http 591718 Jan 15  2017 updater.phar

修改updater文件夹的权限之后发现错误仍然在,推断是需要给更上一层文件夹nextcloud修改权限

[root@66ae53f080fc nextcloud]# cd ..
[root@66ae53f080fc webapps]# ls
nextcloud  php-apcu
[root@66ae53f080fc webapps]# chmod -R 777 nextcloud/

再次点击 Retry update,更新完成。

Keep maintenance mode active?

有两个选项
Yes (for usage with command line tool)
No (for usage of the web based updater)
,选择了Yes,然后提示跳转,结果其实页面一直在维修页面
参考Stuck in “Keep maintenance mode active?” when update to v 10.0.2 的解决方案

Please check the nextcloud.log-file in the data folder. If there is nothing and it’s just the maintenance mode, you can try to set maintenance mode in your config/config.php to false.

找到config.php文件

[root@66ae53f080fc webapps]# find -name config.php
./nextcloud/apps/files_external/lib/config.php
./nextcloud/data/updater-ocaxdj9yd0ef/backups/nextcloud-11.0.1.2/apps/gallery/controller/config.php
./nextcloud/data/updater-ocaxdj9yd0ef/backups/nextcloud-11.0.1.2/apps/files_external/lib/config.php
./nextcloud/data/updater-ocaxdj9yd0ef/backups/nextcloud-11.0.1.2/config/config.php
./nextcloud/config/config.php

很确定参考的解决方案指的是./nextcloud/config/config.php,查看一下文本之后cat config.php,确定无疑。

当时发现无论用nano还是vim都提示can not found command ,并且无法使用yumapt

[root@66ae53f080fc webapps]# bash --version
GNU bash, version 4.4.11(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

受自己的知识限制未解决该问题。
不过想到一个迂回的解决办法。思路是,docker的镜像文件还是在归属在Linux目录下,在docker之外修改文件。

#退出docker
[root@66ae53f080fc webapps]# exit
exit
ubuntu@VM-0-5-ubuntu:~$sudo find -name config.php

发现不能找到任何文件,推断是需要在root权限下搜索,先搜索docker,找到/var/lib/docker

ubuntu@VM-0-5-ubuntu:~$ cd /var/lib/docker/
# docker目录下限制了权限
ubuntu@VM-0-5-ubuntu:/var/lib/docker$ ls
ls: cannot open directory '.': Permission denied
# sudo,成功执行ls
ubuntu@VM-0-5-ubuntu:/var/lib/docker$ sudo ls
builder  containerd  containers  image  network  overlay2  plugins  runtimes  swarm  tmp  trust  volumes
# 切换root
ubuntu@VM-0-5-ubuntu:/var/lib/docker$ sudo su
# whereis 不好用
root@VM-0-5-ubuntu:/var/lib/docker# whereis config.php
config: /usr/share/man/man5/config.5ssl.gz
# 有点多,不好确认是哪个
root@VM-0-5-ubuntu:/var/lib/docker# find -name config.php
./overlay2/612ea56b28225c004be32b2b3a0f150a03296bf206eaed5a4e1f68cf5bb2f53f/diff/usr/share/webapps/nextcloud/config/config.php
./overlay2/0f95ea68f4483e691e577ce7ac1ba4501c70e4dbb789dd8a30adea9826e93f3b/diff/usr/share/webapps/nextcloud/config/config.php
./overlay2/2ee04fb978f12b6e7343ef310aeaec72abfbf95dfad20691fe2227fd05fd1d03/diff/usr/share/webapps/nextcloud/apps/files_external/lib/config.php
./overlay2/2ee04fb978f12b6e7343ef310aeaec72abfbf95dfad20691fe2227fd05fd1d03/diff/usr/share/webapps/nextcloud/data/updater-ocaxdj9yd0ef/backups/nextcloud-11.0.1.2/apps/gallery/controller/config.php
./overlay2/2ee04fb978f12b6e7343ef310aeaec72abfbf95dfad20691fe2227fd05fd1d03/diff/usr/share/webapps/nextcloud/data/updater-ocaxdj9yd0ef/backups/nextcloud-11.0.1.2/apps/files_external/lib/config.php
./overlay2/2ee04fb978f12b6e7343ef310aeaec72abfbf95dfad20691fe2227fd05fd1d03/diff/usr/share/webapps/nextcloud/data/updater-ocaxdj9yd0ef/backups/nextcloud-11.0.1.2/config/config.php
./overlay2/2ee04fb978f12b6e7343ef310aeaec72abfbf95dfad20691fe2227fd05fd1d03/diff/usr/share/webapps/nextcloud/config/config.php
./overlay2/2ee04fb978f12b6e7343ef310aeaec72abfbf95dfad20691fe2227fd05fd1d03/merged/usr/share/webapps/nextcloud/apps/files_external/lib/config.php
./overlay2/2ee04fb978f12b6e7343ef310aeaec72abfbf95dfad20691fe2227fd05fd1d03/merged/usr/share/webapps/nextcloud/data/updater-ocaxdj9yd0ef/backups/nextcloud-11.0.1.2/apps/gallery/controller/config.php
./overlay2/2ee04fb978f12b6e7343ef310aeaec72abfbf95dfad20691fe2227fd05fd1d03/merged/usr/share/webapps/nextcloud/data/updater-ocaxdj9yd0ef/backups/nextcloud-11.0.1.2/apps/files_external/lib/config.php
./overlay2/2ee04fb978f12b6e7343ef310aeaec72abfbf95dfad20691fe2227fd05fd1d03/merged/usr/share/webapps/nextcloud/data/updater-ocaxdj9yd0ef/backups/nextcloud-11.0.1.2/config/config.php
./overlay2/2ee04fb978f12b6e7343ef310aeaec72abfbf95dfad20691fe2227fd05fd1d03/merged/usr/share/webapps/nextcloud/config/config.php
./overlay2/1abb9cea8df7ea562dda4be2629257e89a2c371e6c3df28bf0ad934fe45c8996/diff/usr/share/webapps/nextcloud/apps/gallery/controller/config.php
./overlay2/1abb9cea8df7ea562dda4be2629257e89a2c371e6c3df28bf0ad934fe45c8996/diff/usr/share/webapps/nextcloud/apps/files_external/lib/config.php

灵机一动,进入docker,在config.php同级目录下新建文件123qwe.txt,

# find -name 123qwe.txt
./var/lib/docker/overlay2/8c5e9b62bf7b3f479d5f3bd0a26790c6db818bd117eaee93d02d9596543cc320/diff/usr/share/webapps/nextcloud/config/123qwe.txt
./var/lib/docker/overlay2/8c5e9b62bf7b3f479d5f3bd0a26790c6db818bd117eaee93d02d9596543cc320/merged/usr/share/webapps/nextcloud/config/123qwe.txt

先尝试修改在diff下的config.php,在另一个终端查看cat config.php,发现修改成功。赞!
再次刷新页面,出现开始更新按钮,点击开始更新,静静等待几分钟,完成。

有可用的新版本: Nextcloud 13.0.1

打开后台发现仍然可以继续更新,打开更新器,继续更新,完美走到Keep maintenance mode active?,这次选择No (for usage of the web based updater),点击Go back to your Nextcloud instance to finish the update,跳转页面,点击开始更新。等待几分钟,更新完成。

你可能感兴趣的:(#,Docker,nextcloud)