CentOS7 安装docker版Nextcloud

CentOS7.6 安装Docker版Nextcloud,使用官方docker-compose部署


安装docker

curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
systemctl start docker
systemctl enable docker

CentOS7 安装docker版Nextcloud


安装docker-compose

#最新版docker-compose版本地址https://github.com/docker/compose/releases
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version

CentOS7 安装docker版Nextcloud


创建docker compose文件

yum install -y wget vim
mkdir -p ~/docker/docker-compose/nextcloud
cd ~/docker/docker-compose/nextcloud
mkdir web
cd web
wget https://raw.githubusercontent.com/nextcloud/docker/master/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/web/Dockerfile
wget https://raw.githubusercontent.com/nextcloud/docker/master/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/web/nginx.conf
cd ..
wget https://raw.githubusercontent.com/nextcloud/docker/master/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/db.env
wget https://raw.githubusercontent.com/nextcloud/docker/master/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/docker-compose.yml


配置docker-compose

yml配置文件格式要求严格,每一行空格不能多也不能少,否则会报错

vim /root/docker/docker-compose/nextcloud/db.env
修改为
MYSQL_PASSWORD=MYSQL密码
MYSQL_DATABASE=nextcloud
MYSQL_USER=nextcloud

修改数据库密码,nginx端口,数据持久化路径

vim /root/docker/docker-compose/nextcloud/docker-compose.yml
修改为
version: '3'

services:
  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=MYSQL密码
    env_file:
      - db.env

  redis:
    image: redis:alpine
    restart: always

  app:
    image: nextcloud:fpm-alpine
    restart: always
    volumes:
      - nextcloud:/var/www/html
    environment:
      - MYSQL_HOST=db
      - REDIS_HOST=redis
    env_file:
      - db.env
    depends_on:
      - db
      - redis

  web:
    build: ./web
    restart: always
    ports:
      - 8888:80     #本机端口8888,容器内端口80
    volumes:
      - nextcloud:/var/www/html:ro
    depends_on:
      - app

  cron:
    image: nextcloud:fpm-alpine
    restart: always
    volumes:
      - nextcloud:/var/www/html
    entrypoint: /cron.sh
    depends_on:
      - db
      - redis

  volumes:
    db:
    nextcloud:


BUILD镜像并运行

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://9xtainqf.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker


docker-compose build --pull

CentOS7 安装docker版Nextcloud


docker-compose up -d

CentOS7 安装docker版Nextcloud


docker ps
docker images

CentOS7 安装docker版Nextcloud


页面文件路径

cd /var/lib/docker/volumes/nextcloud_nextcloud/_data

数据库文件路径

cd /var/lib/docker/volumes/nextcloud_db/_data


更新容器
docker pull nextcloud
docker stop <nextcloud_container>
docker rm <nextcloud_container>
docker run <OPTIONS> -d nextcloud
进入容器
docker exec -it <container_id> bash



更新日期: 2019年03月13日
文章标签: Linux
文章链接: https://www.vos.cn/os/289.html  
版权说明:如非注明,本站文章均为vOS原创,转载请注明出处和附带本文链接。