Docker+Nextcloud快速部署个人网盘

各位大佬好,,,萌新顾北清又回来更新了,今天要快速部署一个人网盘。
有多快呢,,,5分钟吧,因为我们使用Docker部署。
Docker基础可以看看我之前的博文。(点这里点这里
那么,,,开始吧。

实验环境:小伙伴的阿里云服务器,安装的是Centos7的系统,要安装的网盘叫Nextcloud
如果是debain,需要先修改一下源。
在/etc/apt/sources.list文件下添加一条源

deb http://http.debian.net/debian jessie-backports main

然后执行apt-get update命令更新源。

下面开始安装
第一步
老规矩,先安装Docker环境.
命令如下:

[root@izt8mvnno1ny1dz ~]# yum install -y docker
Loaded plugins: fastestmirror
base                                                                                                                                    | 3.6 kB  00:00:00
epel                                                                                                                                    | 3.2 kB  00:00:00
extras                                                                                                                                  | 3.4 kB  00:00:00
updates                                                                                                                                 | 3.4 kB  00:00:00
Loading mirror speeds from cached hostfile
Package 2:docker-1.13.1-74.git6e3bb8e.el7.centos.x86_64 already installed and latest version
Nothing to do

我这里已经安装完成就不重复安装了。
启动docker并设置自启:

[root@izt8mvnno1ny1dz ~]# systemctl start docker
[root@izt8mvnno1ny1dz ~]# systemctl enable docker

第二步
查找Nextcloud网盘的镜像

[root@izt8mvnno1ny1dz ~]# docker search nextcloud
INDEX       NAME                                      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/nextcloud                       A safe home for all your data                   561       [OK]
docker.io   docker.io/linuxserver/nextcloud           A Nextcloud container, brought to you by L...   81
docker.io   docker.io/greyltc/nextcloud               Nextcloud: a safe home for all your data. ...   38                   [OK]
docker.io   docker.io/wonderfall/nextcloud            All-in-one alpine-based Nextcloud image.        36                   [OK]
docker.io   docker.io/rootlogin/nextcloud             Nextcloud docker image running on top of N...   17                   [OK]
docker.io   docker.io/lsioarmhf/nextcloud             ARMHF based Linuxserver.io image of nextcloud   9
docker.io   docker.io/arm32v7/nextcloud               A safe home for all your data                   8
docker.io   docker.io/benyanke/nextcloud              Fork of wonderfall/nextcloud, since it is ...   7                    [OK]
docker.io   docker.io/ownyourbits/nextcloudpi         NextCloud ARM docker container                  7
docker.io   docker.io/sameersbn/nextcloud             Dockerized Nextcloud                            7                    [OK]
docker.io   docker.io/ownyourbits/nextcloudpi-armhf   NextCloudPi ARM docker container                6
docker.io   docker.io/hoellen/nextcloud               Based on wonderfall/nextcloud                   5                    [OK]
docker.io   docker.io/aheimsbakk/nextcloud            DEPRECATED in favor of the Nextcloud webin...   2                    [OK]
docker.io   docker.io/crazymax/nextcloud              Nextcloud Docker image based on Alpine Lin...   1
docker.io   docker.io/lsioarmhf/nextcloud-aarch64     ARM64 based Linuxserver.io image of nextcl...   1
docker.io   docker.io/zerpex/nextcloud-ocdl           Nextcloud with ocDownloader pre-requiresites    1                    [OK]
docker.io   docker.io/avhost/docker-nextcloud         nextcloud as docker service                     0                    [OK]
docker.io   docker.io/bunix42/nextcloud               Docker Image for Nextcloud, based on the o...   0
docker.io   docker.io/dheaps/nextcloud-cron           Cron service for Nextcloud                      0                    [OK]
docker.io   docker.io/ftsystems/nextcloud             Nextcloud container based on the owncloud ...   0
docker.io   docker.io/gorlug/nextcloud                https://nextcloud.com/                          0                    [OK]
docker.io   docker.io/sesceu/nextcloud                nextcloud with cron and imap-auth               0                    [OK]
docker.io   docker.io/trollin/nextcloud                                                               0
docker.io   docker.io/whatwedo/nextcloud              Nextcloud powered by Apache                     0                    [OK]
docker.io   docker.io/zyrill/nextcloud                 Nextcloud v12 based on php:fpm-alpine          0

依旧老规矩,使用官方镜像

第三步
拉取官方的Docker镜像

[root@izt8mvnno1ny1dz ~]# docker pull docker.io/nextcloud
Using default tag: latest
Trying to pull repository docker.io/library/nextcloud ...
latest: Pulling from docker.io/library/nextcloud
802b00ed6f79: Already exists
59f5a5a895f8: Pull complete
6898b2dbcfeb: Pull complete
8e0903aaa47e: Pull complete
2961af1e196a: Pull complete
71f7016f79a0: Pull complete
5e1a48e5719c: Pull complete
7ae5291984f3: Pull complete
725b65166f31: Pull complete
e90b121f9520: Pull complete
b5a272809bbd: Pull complete
f045f3ae0e2b: Pull complete
7f51c9ea2d8e: Pull complete
5aa9d0ed164a: Pull complete
8eea44e2bfc7: Pull complete
5302ebd5abce: Pull complete
78f0335decb3: Pull complete
1a2f85124682: Pull complete
ed4cec78a159: Pull complete
a68e1b656d3d: Pull complete
d0b66f00fda7: Pull complete
45c9777c18b5: Pull complete
Digest: sha256:c8d1091cc86051dc5e8de0114e3121fe0562cb417c56f2644ed92838008d8806
Status: Downloaded newer image for docker.io/nextcloud:latest

镜像拉取完成

第四步
容器拉取到本地之后,就该启用容器了。

[root@izt8mvnno1ny1dz ~]# docker run -d --restart=always --name nextcloud -p 80:80 -v /root/nextcloud:/data docker.io/nextcloud
ae96013c7f0ab05194a4488d1fa61b1c6274c272a53b3d418418b56a88e2e230
[root@izt8mvnno1ny1dz ~]# docker ps -a
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                NAMES
ae96013c7f0a        docker.io/nextcloud   "/entrypoint.sh ap..."   6 seconds ago       Up 6 seconds        0.0.0.0:80->80/tcp   nextcloud

这里可以看到已经在后台运行了,这就部署好了。

第五步
在浏览器地址栏输入你的IP地址,可以访问到NextcloudWeb页面。

如果搭建完成但是访问不到:
(1)使用云服务器的小伙伴们,首先检查一下是否在云服务器的安全组里面放行80端口。

(2)重启一下docker服务,命令如下:

[root@izt8mvnno1ny1dz ~]# systemctl restart docker

(3)如果还是不行,那么就关闭防火墙服务吧。

[root@izt8mvnno1ny1dz ~]# systemctl stop firewalld
[root@izt8mvnno1ny1dz ~]# systemctl status firewalld    //查看一下防火墙状态
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
    Docs: man:firewalld(1)

Sep 20 13:44:49 izt8mvnno1ny1dz systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 20 13:44:50 izt8mvnno1ny1dz systemd[1]: Started firewalld - dynamic firewall daemon.
Sep 20 13:44:57 izt8mvnno1ny1dz systemd[1]: Stopping firewalld - dynamic firewall daemon...
Sep 20 13:44:57 izt8mvnno1ny1dz systemd[1]: Stopped firewalld - dynamic firewall daemon.
Sep 20 15:33:49 izt8mvnno1ny1dz systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 20 15:33:49 izt8mvnno1ny1dz systemd[1]: Started firewalld - dynamic firewall daemon.
Sep 20 15:34:58 izt8mvnno1ny1dz systemd[1]: Stopping firewalld - dynamic firewall daemon...
Sep 20 15:34:58 izt8mvnno1ny1dz systemd[1]: Stopped firewalld - dynamic firewall daemon.

接着完成完成网盘管理员账号的注册,使用默认数据库(当然,也可以起一个Mysql的容器来连接),然后完成注册,就可以登录了。


这样就愉快的搭建完成了,是不是五分钟快速搭建!

posted @ 2018-09-21 21:05  顾北清  阅读(18791)  评论(6编辑  收藏