工具blog|Docker配置Webdav实现Zotero同步-阿里云服务器

Zotero多端同步可以有效地在不同设备随时访问文献,极大地方便论文阅读和共享。本文章介绍如何配置Zotero的服务器,用来支持多端同步。

换了新服务器,先是配置了Webdav,设置了config文件。但是Zotero连接一直报错(如下图所示)。于是怒换Docker实现文件同步。
在这里插入图片描述

前置环境声明

服务器:阿里云2核2G轻量云服务器
linux: CentOS 7.9

[root@xxxx]# lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.9.2009 (Core)
Release:        7.9.2009
Codename:       Core

安装docker

卸载旧版本

$ sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

使用yum安装(国内源)

$ sudo yum install -y yum-utils
$ sudo yum-config-manager \
    --add-repo \
    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

$ sudo sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo

# 官方源
# $ sudo yum-config-manager \
#     --add-repo \
#     https://download.docker.com/linux/centos/docker-ce.repo

安装Docker

$ sudo yum install docker-ce docker-ce-cli containerd.io

启动Docker

$ sudo systemctl enable docker
$ sudo systemctl start docker

测试Docker是否安装正确

$ docker run --rm hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

若能正常输出以上信息,则说明安装成功。

拉取镜像

$ docker pull bytemark/webdav

启动

设置防火墙

首先规划你所需要的端口。笔者使用7777作为端口。
第一步,打开阿里云防火墙界面,将端口如下图所示添加:
在这里插入图片描述
第二步,打开linux界面,使用下面的命令开启端口:

# 查看开启端口
firewall-cmd --list-all
# 开启指定端口
firewall-cmd --zone=public --add-port=7777/tcp --permanent
# 更新防火墙
firewall-cmd --reload

开启和更新防火墙成功后会输出”success"信息。

通过Docker启动

首先规划Zotero存放论文的文件夹。
笔者使用/home/webdav/zotero/存放。有blog说需要把该文件夹放到docker安装的文件夹下,在我看来不是必要的。

docker run --restart always -v /home/webdav/zotero:/var/lib/dav/data \
    -e AUTH_TYPE=Digest -e USERNAME=your_DIY_usr_name -e PASSWORD=your_DIY_pwd \
    --publish your_DIY_port(eg:7777):80 --name your_DIY_name \
    -e LOCATION=/webdav/zotero -d bytemark/webdav

笔者使用的命令示例:

docker run --restart always -v /home/webdav/zotero:/var/lib/dav/data \
    -e AUTH_TYPE=Digest -e USERNAME=your_usr_name -e PASSWORD=your_DIY_pwd \
    --publish 7777:80 --name webdav \
    -e LOCATION=/webdav/zotero -d bytemark/webdav
  • -v orig_path:/var/lib/dav/data 指的是将你的orig_path映射到/var/lib/dav/data共享文件夹。
  • –publish 7777:80 是将7777端口作为访问端口。
    LOCATION=/webdav/zotero 是将该路径作为访问路径。注意由于Zotero限制,该LOCATION一定要以/zotero结尾。

停止容器(在你需要重新创建的时候才需要使用,不是正常流程必须)

docker stop webdav

访问共享文件夹

通过刚才设定的publish和LOCATION,使用下面格式的链接访问共享文件夹。

http://your_server_public_IP:your_port/your_LOCATION/

笔者使用的命令为:

http://ServerIP:7777/webdav/zotero/

首次访问需要登陆,使用刚才设定的user_name和password即可访问。成功后如下图所示:
在这里插入图片描述

Zotero验证

打开Zotero-编辑-首选项-同步,按照下图所示选择。 其中port和后面的路径根据需要可以更换。
在这里插入图片描述
然后显示验证通过,可以愉快地实现文件同步啦~
在这里插入图片描述

参考博客:
[1]: https://blog.csdn.net/u011459717/article/details/128758573 写得比较抽象,需要摸索踩坑
[2]: https://yeasy.gitbook.io/docker_practice/install/centos
[3]: http://nas.zwbcc.cn:8090/archives/1679725710280 需要鉴别里面的有效信息

  • 11
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
阿里云服务器(ECS)是阿里云提供的一种云计算服务,而Docker是一种开源的容器化平台。在阿里云服务器上使用Docker可以帮助用户更高效地部署和管理应用程序。 Docker的核心概念是容器,它是一种轻量级的虚拟化技术,可以将应用程序及其依赖打包成一个独立的可执行单元,称为容器。这样,应用程序可以在任何支持Docker的环境中运行,而不需要担心环境差异性带来的问题。 在阿里云服务器上使用Docker,您可以享受以下好处: 1. 灵活性:Docker容器可以快速部署和启动,使您的应用程序能够快速响应变化的需求。 2. 资源利用率:Docker容器共享主机操作系统的内核,因此可以更高效地利用服务器资源。 3. 可移植性:Docker容器可以在不同的环境中运行,无需担心环境差异性。 4. 可扩展性:通过使用Docker容器编排工具(如Docker Compose和Kubernetes),您可以轻松地扩展和管理多个容器。 如果您想在阿里云服务器上使用Docker,您可以按照以下步骤进行操作: 1. 在阿里云上创建一台ECS实例,并确保已安装Docker。 2. 使用Docker命令或Docker Compose编写Dockerfile和docker-compose.yml文件,描述您的应用程序和其依赖。 3. 构建Docker镜像并将其推送到阿里云的容器镜像仓库(如阿里云容器镜像服务)。 4. 在ECS实例上运行Docker容器,可以使用Docker命令或Docker Compose进行管理。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值