搭建私人小世界
owncloud私人云盘
[https://www.cnblogs.com/mecforlove/p/10392913.html]
docker pull owncloud
docker pull mysql:5.7
docker run --name owncloud-mysql -e MYSQL_ROOT_PASSWORD=qs██████████ \
-v /home/server/mysql/conf/my.cnf:/etc/my.cnf \
-v /home/server/mysql/data:/var/lib/mysql \
-d mysql:5.7
docker run --name owncloud -p 89:80 --link owncloud-mysql:db -d owncloud
docker run --name owncloud -p 89:80 --link acc3716864ba44d656f0fddea936f1a4c3be28d069a212627c5fa23310f47124:db -d owncloud
数据库地址db:3306
docker ps -a #查看所有容器
docker logs 容器id #查看容器日志
最终结果是连接不上mysql数据库,用的默认sqlite
mkdir /home/server/sqlite
chmod 777 /home/server/sqlite
docker run --name owncloud -p 89:80 -v /home/server/sqlite:/var/www/html/data -d owncloud
访问192.168.50.80:89 账号qsbye(首次登陆后设置)
添加smbclient
docker \
FROM owncloud:latest
RUN set -x; \
apt-get update \
&& apt-get install -y smbclient \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/cache/apt/archives/*
或者
docker exec -it owncloud bash
apt-get update
apt-get install -y smbclient
apt install smbclient libsmbclient-dev
pecl install smbclient
docker-php-ext-enable smbclient
然后重启docker容器
samba容器实现共享
sudo docker pull dperson/samba:latest
sudo docker run --name samba \
--restart always \
-p 139:139 -p 445:445 \
--net amber-net \
--ip 172.20.0.30 \
-e USERID="0" \
-e GROUPID="0" \
-v /mnt/USB64G/samba/share:/share/samba \
-v /mnt/USB64G/owncloud/data/Yogile/files:/share/Yogile \
-m 512m \
-d dperson/samba:latest \
-u "admin;admin密码" \
-u "family;" \
-s "family;/share/samba/family;yes;no;yes;all;all;all;家庭共享"
在线音乐播放器
docker pull deluan/navidrome:latest
docker run --name navidrome -p 82:4533 -v /home/server/files/music:/music:ro -v /home/server/mysql/data:/data -d deluan/navidrome:latest
#下载音乐文件并重命名
wget http://59.110.45.28/m/api/url/yqe/id/4177jBnnNvaq47SvnbVhRM4eIbPraDaWSvs_XVmi5PA2HkyGDPh5tf30vMcN2_I/format/HQ -O 冰河时代-G.E.M.邓紫棋.mp3
然后访问192.168.50.80:82
http服务器
lamp服务搭建->内网导航主页
docker pull tutum/lamp:latest
wordpress博客
mkdir -p /server/www/wordpress
chmod 777 /server/www/wordpress
docker run -d -p 81:80 -v /home/server/www/wordpress wordpress
#连接数据库(不用这个命令)
mysql -h bdm775972575.my3w.com -u bdm775972575 -p --ssl-mode=DISABLED
#暂时用阿里云数据库,表名wordpress_,目录/home/server/www/wordpress
账户:qsbye
密码:qs█████
mysql数据库
获取docker镜像
docker pull mysql
先启动一次容器以获取配置文件
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD= 09f9add0ab1ad024e7a7c20ac2c2f48a -d mysql -v /var/lib
docker exec -it mysql bash
mysql --help | grep my.cnf
my.cnf
"Destination": "/var/lib/mysql",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
],
"Config": {
"Hostname": "a979059c7e7d",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"3306/tcp": {},
"33060/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"MYSQL_ROOT_PASSWORD=root",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.14",
"MYSQL_MAJOR=8.0",
"MYSQL_VERSION=8.0.30-1.el8",
"MYSQL_SHELL_VERSION=8.0.30-1.el8"
],
"Cmd": [
"mysqld"
],
"Image": "mysql",
"Volumes": {
"/var/lib/mysql": {}
},
复制配置文件
sudo mkdir -p /server/mysql/conf
sudo mkdir -p /server/mysql/data
sudo docker cp mysql:/etc/my.cnf /server/mysql/conf
docker rm -f mysql
启动容器
docker run --rm --name mysql \
-p 3306:3306 -e MYSQL_ROOT_PASSWORD=09f9add0ab1ad024e7a7c20ac2c2f48a \
--network=host \
-v /home/server/mysql/conf/my.cnf:/etc/my.cnf \
-v /home/server/mysql/data:/var/lib/mysql \
--restart=on-failure:3 \
-d mysql
然后进入mysql:
docker exec -it mysql bash
mysql -u root -p;
Enter password:
CREATE USER `qsbye`@`%` IDENTIFIED BY '09f9add0ab1ad024e7a7c20ac2c2f48a';
GRANT ALL PRIVILEGES ON *.* TO 'qsbye'@'%';
FLUSH PRIVILEGES;
ALTER user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '09f9add0ab1ad024e7a7c20ac2c2f48a';
#在服务器内部可以直接填写docker的容器别名或id以作为数据库网络地址
#外部访问
mysql -h 192.168.50.80 -u qsbye -p
内网DNS搭建
查询了,好像没有.bye顶级域名,所以内网自己弄一个
分配www.hi.bye(192.168.50.80:80)为导航主页,192.168.50.80:53是DNS入口
docker pull ustclug/dnspod-sr:latest
readthedocs
docker pull gyzpunk/readthedocs:latest
docker run -d -p 8000:8000 gyzpunk/readthedocs:latest
然后访问127.0.0.1:8000
在线VScode(code server)
docker pull codercom/code-server:4.8.0-bullseye
mkdir -p /home/server/files/.config
cd /home/server/files
docker run -it --name code-server -p 94:8080 \
-v "$PWD/.config:/home/coder/.config" \
-v "$PWD:/home/coder/project" \
-u "$(id -u):$(id -g)" \
--user root \
-e CHOWN_EXTRA=/home/server/files \
-d codercom/code-server:4.8.0-bullseye
不要试图用latest标签下载镜像,因为有些最新镜像不可用
访问192.168.50.80:94
#查看密码
docker exec -it code-server /bin/sh
cat ~/.config/code-server/config.yaml
#输出:
bind-addr: 127.0.0.1:8080
auth: password
password: d786fa38ca8813f508bff333
cert: false
#然后exit退出终端即可
进行常规设置,设置中文
gitlab
[https://blog.csdn.net/wsdn782368398/article/details/89938163]
[https://blog.csdn.net/qq_38531706/article/details/122235568]
gitlab类似github
docker pull gitlab/gitlab-ce:latest
cd /home/server
mkdir gitlab
mkdir -p gitlab/config
mkdir -p gitlab/logs
mkdir -p gitlab/data
//或者使用mkdir -p ./gitlab/{config,logs,data}
docker run -it --hostname gitlab-server -p 90:443 -p 95:80 -p 96:22 --name gitlab -u root --restart always -e CHOWN_EXTRA=/home/server/gitlab --volume "$PWD/gitlab/config:/etc/gitlab" --volume "$PWD/gitlab/logs:/var/log/gitlab" --volume "$PWD/gitlab/data:/var/opt/gitlab" -d gitlab/gitlab-ce:latest /bin/bash -c "gitlab-ctl start"
没有数据持久化处理的启动方式:
docker run -it -p 97:80 gitlab/gitlab-ce:latest
根据机器配置有一个等待时间,内部服务启动。可以进入容器查看服务启动状态
docker ps
或
docker exec -it gitlab /bin/bash
#查看本机端口状态
netstat -tnl
访问192.168.50.80:95进入网页后台
然而注册后无法登录
显示默认root密码
设置root账户密码
# 1.进入容器
docker exec -it gitlab /bin/bash
# 2.启动Ruby on Rails控制台,需要等待较长时间
gitlab-rails console
# 3.找到root用户,以下方式或者 user = User.find_by(email: '[email protected]')
user = User.where(id: 1).first
# 4.更改密码,这里需要8位密码,少了会保存失败
user.password = '你的密码'
# 5.确认密码
user.password_confirmation = '你的密码'
# 6.保存更改
user.save
然后在后台添加账户
总结
经过如上一顿操作,docker ps显示如下:
端口占用如下:
192.168.50.80:端口 | 服务 |
---|---|
53 | dns服务 |
80 | 网址导航 |
81 | wordpress博客 |
82 | 在线音乐 |
83 | lxde云桌面 |
84 | emqx_mqtt后台 |
85-88 | emqx_mqtt服务相关 |
89 | owncloud云盘 |
90 | gitlab后台:443 |
91 | Jupyter在线编程 |
92 | 安卓云手机 |
93 | gitbook |
94 | 在线VScode |
95 | gitlab后台:80 |
96 | gitlab:22 |
9090 | Cockpit服务器运维后台 |
私人小世界搭建到这里,应该已经有:git,音乐在线播放,博客,网址导航,云盘,gitbook,dns,mysql,云桌面,emqx
docker设置相关
docker搜索镜像
比如查找关于网页服务器的
docker search -s 10 lamp
更改docker镜像默认下载目录
更改docker默认位置
[https://blog.51cto.com/u_15414237/5285354]
docker info
vi /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --graph=/home/docker
mkdir -p /home/docker #这里就是新的挂载目录
systemctl daemon-reload
systemctl restart docker
设置容器开机自启
sudo docker update --restart=always f0fc627a1096
检查容器网络联通
安装ping工具
最近在使用docker,通过镜像创建的容器里面,使用ping 命令报错。
安装ping工具
apt-get update
apt-get install inetutils-ping
apt install joe
docker容器之间网络互联
docker启动报错Main PID: 31870 (code=exited, status=1/FAILURE)
解决:如果是配置了国内镜像,并且镜像文件为/etc/docker/daemon.json,则修改文件后缀为.conf即可正常启动docker 服务
sudo systemctl start docker
sudo systemctl status docker
进入容器
docker exec -it 228ae947b20e /bin/bash
查看路由表
route
查看网桥
brctl show
查看网络信息
cat /etc/hosts
添加路由信息
vim /etc/hosts
添加
172.17.0.2 mysql
joe /etc/hosts
[https://zhuanlan.zhihu.com/p/342694723]
ctrl+K+H帮助
ctrl+K+X保存文件并离开
查看网络
hostname -I
查看网络
docker network inspect bridge
查看网络
ip addr show
退出容器终端而不停止容器
使用分离序列,CTRL + p CTRL + q
安装docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
用户自定义docker bridge网桥
docker network create my-net
docker network connect my-net 4a51a604cd51 # 将Web服务加入my-net网络中
docker network connect my-net 43ca369a0c0f # 将mysql服务加入my-net网络中
docker network inspect my-net
openEuler从rpm地址安装mysql(失败)
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-x86_64/mysql-community-server-8.0.28-1.el7.x86_64.rpm
yum -Uvh mysql-8.0-community-el7-x86_64/mysql-community-common-8.0.28-1.el7.x86_64.rpm
https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-x86_64/mysql-community-libs-8.0.28-1.el7.x86_64.rpm
https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-x86_64/mysql-community-common-8.0.28-1.el7.x86_64.rpm
https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-x86_64/mysql-community-client-8.0.28-1.el7.x86_64.rpm
https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-x86_64/mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-common-8.0.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-libs-8.0.28-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-client-8.0.28-1.el7.x86_64.rpm --nodeps --force
rpm -ivh mysql-community-server-8.0.28-1.el7.x86_64.rpm --nodeps --force
依次执行下面命令安装
(几个安装包有依赖关系,所以执行有先后)
安装第一个包时,有可能包依赖冲突,将冲突包卸载后重新安装即可。
安装包1:mysql-community-common-5.7.20-1.el7.x86_64.rpm
安装包2:mysql-community-libs-5.7.20-1.el7.x86_64.rpm
安装包3:mysql-community-client-5.7.20-1.el7.x86_64.rpm
安装包4:mysql-community-server-5.7.20-1.el7.x86_64.rpm
初始化:
sudo yum install -y openssl-devel
mysqld --initialize --user=mysql
centos查看端口号占用
yum -y install net-tools
所有端口占用
netstat -AaLlnW
查看80端口
netstat -AaLlnW | grep 80
或者
yum -y install lsof
lsof -i :80