赞
踩
sudo su -
NAME_NET=nc_net
NAME_MAIN=nc_main
NAME_DB=nc_db
PWD_DB=my-secret-pw
EXPOSE_PORT=8081
# 创建Docker网络
docker network create \
--gateway 192.168.0.1 \
--subnet 192.168.0.0/16 \
$NAME_NET
docker network ls
# 拉取镜像
docker pull nextcloud
docker pull mysql
# 运行数据库
docker run -d \
--name $NAME_DB --network $NAME_NET \
-e MYSQL_ROOT_PASSWORD=$PWD_DB \
mysql
docker ps
docker logs -t $NAME_DB
# 配置数据库
docker exec -it $NAME_DB /bin/bash
>mysql -h127.0.0.1 -uroot -p
>$PWD_DB
>># 创建数据库及其管理员
>>QUIT;
># Ctrl + D
# 运行NextCloud
sudo docker run -d \
-p $EXPOSE_PORT:80 \
--name $NAME_MAIN --network $NAME_NET \
nextcloud
docker ps
docker logs -t $NAME_MAIN
# 添加NextCloud到默认网络
docker network connect bridge $NAME_MAIN
docker restart $NAME_MAIN
docker ps
# 检查网络
docker inspect $NAME_NET | grep 'Containers' -A15
netstat -tnlp | grep 8081
# 配置NextCloud
# http://192.168.?.?:$EXPOSE_PORT
创建数据库及其管理员:
-- nextcloud : 数据库名
-- nextcloud_root : 用户名
-- nextcloud_pwd : 用户密码
CREATE DATABASE `nextcloud` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci';
CREATE USER 'nextcloud_root'@'192.168.%.%' IDENTIFIED BY 'nextcloud_pwd';
REVOKE ALL ON *.* FROM 'nextcloud_root'@'192.168.%.%';
GRANT ALL PRIVILEGES ON `nextcloud`.* TO 'nextcloud_root'@'192.168.%.%' WITH GRANT OPTION;
-- 检查
SHOW DATABASES;
SELECT User,Host from mysql.user;
通过不被信任的域名访问:
docker exec -it $NAME_MAIN/bin/bash
apt update
apt install vim
vim ./config/config.php
'trusted_domains' =>
array (
0 => 'localhost',
1 => 'server1.example.com',
),
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。