docker installation
First add docker source
sudo apt update
sudo apt install docker.io
docker replace domestic Mirror
1. configuration script as follows:
#!/bin/bash
cat>/etc/docker/daemon.json<<EOF
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
systemctl restart docker
2. In addition to accelerate a program, execute the following command to :( The most effective way)
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
sudo service docker restart
3. Another home mirrors
/etc/docker/daemon.json
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
rancher installation
1. docker can simply open below, or to automatically download the appropriate image
sudo docker run -d --restart=always -p 18080:8080 rancher/server
Local port 18080, 8080 is docker internal port
2. Set host registration address
System Management - "System Settings, set the other host address registered address
Can not mu01, because there is no corresponding hostname docker
3. Other host-to-host registration
sudo docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.11 http://192.168.0.100:18080/v1/scripts/99E8CCD2B90632F71865:1546214400000:8568zavvinQyUJzzFWxKnURi7g
4 创建实例
添加环境模板之后才能创建相应的环境实例
就可以添加主机了,这里和default环境一样
点击k8s可以看到k8s环境
5 在rancher的cli中利用kebuctl来查看结点情况
Get commands with basic output
$ kubectl get services # 列出所有 namespace 中的所有 service
$ kubectl get pods --all-namespaces # 列出所有 namespace 中的所有 pod
$ kubectl get pods -o wide # 列出所有 pod 并显示详细信息
$ kubectl get deployment my-dep # 列出指定 deployment $ kubectl get pods --include-uninitialized # 列出该 namespace 中的所有 pod 包括未初始化的
docker批量删除
如何批量删除Docker中已经停止的容器
方法一:
#显示所有的容器,过滤出Exited状态的容器,取出这些容器的ID,
sudo docker ps -a|grep Exited|awk '{print $1}'
#查询所有的容器,过滤出Exited状态的容器,列出容器ID,删除这些容器
sudo docker rm `docker ps -a|grep Exited|awk '{print $1}'`
方法二:
#删除所有未运行的容器(已经运行的删除不了,未运行的就一起被删除了)
sudo docker stop $(sudo docker ps -a -q)//这句是停止所有容器
sudo docker rm $(sudo docker ps -a -q)
方法三:
#根据容器的状态,删除Exited状态的容器
sudo docker rm $(sudo docker ps -qf status=exited)