必看材料
第一个视频初步理解
https://www.bilibili.com/video/BV1s54y1n7Ev?share_source=copy_web
第二个视频学习Docker
https://www.bilibili.com/video/BV11L411g7U1?share_source=copy_web
图文材料:https://docker.easydoc.net/doc/81170005/cCewZWoN/lTKfePfP
装置与环境配置:https://blog.csdn.net/github_39577257/article/details/107180891
1.运行一个centos容器(版本:centos7.9.2009)
留神:如果说是把这个docker当作开发环境的话举荐应用 --net=host 的形式,省去很多麻烦
docker run -itd --name oldfriend-bt -p 80:80 -p 22:22 -p 21:21 -p 443:443 -p 8888:8888 -p 3306:3306 -p 6379:6379 -p 9500:9500 -p 7700-7720:7700-7720 -v /home/WorkSpace:/www/wwwroot --privileged centos:centos7.9.2009 /usr/sbin/init
docker run -itd -p 80:80 -p 8888:8888 -p 9500:9500 -p 3306:3306 -p 888:888 -v /home/WorkSpace:/www/wwwroot --privileged=true --name="oldfriend-bt" registry.cn-hangzhou.aliyuncs.com/oldfriend/oldfriend-bt /usr/sbin/init
docker run -itd --net=host -v /home/WorkSpace:/www/wwwroot --privileged=true --name="oldfriend-bt-host" registry.cn-hangzhou.aliyuncs.com/oldfriend/oldfriend-bt /usr/sbin/init
2.配置网络
首先须要查看是否存在/etc/sysctl.conf文件,如果不存在就在创立一个,如果存在,则查看net.ipv4.ip_forward项
还有一种办法:https://blog.csdn.net/qq_39774931/article/details/116517589
## 假如 sysctl.conf 文件不存在vi /etc/sysctl.conf## 在 sysctl.conf 中减少 net.ipv4.ip_forward = 1 , 示意容许进行路由转发net.ipv4.ip_forward = 1## 加载参数到内核sysctl -p## 重启网络# service network restart## 重启Dockerservice docker restart## 重启容器# docker restart xxx## 进入容器测试网络连接状况docker exec -it xxx bin/bash ping www.baidu.com# 如果上述做完还是不能够,就重启电脑,# 重启之后还是不能够就反复上述操作在重启电脑
确认容器网路可用之后,就能够开始装置的工具。
装置zsh
# 不强制哈yum install -y zsh# 进入容器docker exec -it xxx bin/zsh
## 补充两个罕用的工具包,包含了 ip vim 工具yum install -y git iproute vim openssh openssh-clients.aarch64 openssh-server.aarch64 epel-release systemd NetworkManager# 各个网站举荐的工具,自行看着选# 装置必要工具# yum install -y yum-utils device-mapper-persistent-data lvm2# 装置必要的一些零碎工具sudo yum install -y yum-utils device-mapper-persistent-data lvm2#装置根底指令yum -y install sudo yum -y install initscripts# 网络工具##如果就习惯用 ifconfig,则须要通过上面命令装置工具包 net-tools,命令如下:yum install net-tools
3.装置宝塔(7.9)
注:如果yum失败,请查看:
https://www.cnblogs.com/houss/p/11286392.html
#装置宝塔## 找个目录放 home 或者 www 都能够cd /home && mkdir oldf-bt && cd oldf-bt## 在oldf-bt目录运行Centos装置脚本yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh ed8484bec#宝塔工具bt
平安配置: https://blog.csdn.net/qq_44402184/article/details/123718815
4.批改宝塔
# 批改docker面版命令行cd /www/server/panel# 编辑文件vi tools.py# 批改宝塔后盾终端面版命令行cd /www/server/panel/class# 编辑文件vi tools.py#批改login页面与宝塔后盾题目
5.应用宝塔
当初就能够应用宝塔了
FAQ
push到阿里云
1.登录阿里云Docker Registry
docker login --username=oldfriend registry.cn-hangzhou.aliyuncs.com
2.将镜像推送到Registry
# 新建一个tag,名字必须跟你注册账号一样docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/oldfriend/xxx:[镜像版本号]# 推上去docker push registry.cn-hangzhou.aliyuncs.com/oldfriend/xxx:[镜像版本号]
3.从Registry中拉取镜像
docker pull registry.cn-hangzhou.aliyuncs.com/oldfriend/xxx:[镜像版本号]
非凡操作将容器做成镜像
docker commit 以后运行的容器名 新镜像名:版本号
丑化终端
https://zhuanlan.zhihu.com/p/342667468
source ~/.zshrc谬误问题:https://www.cnblogs.com/hongdada/p/14043871.html
git下载插件的时候换行符主动转换造成的$ git config --list |grep autocrlfcore.autocrlf=true$ git config core.autocrlf false$ git config --global core.autocrlf false
开机自启动宝塔面板
# zsh终端# 在此文件中增加脚本 bt$ source ~/.zshrc
docker服务无奈启动
报错:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
查看/etc/docker/daemon.json文件,保障是正确的json格局如果还是不行,请替换成上面的配置{ "registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com","https://mirror.ccs.tencentyun.com","https://oldfriend.mirror.aliyuncs.com"]}