安装rancher
使用命令
docker pull rancher/rancher
即可下载rancher相关系统组件。(记住是在你的Master机器上,不是Node机器上)
下载完成以后的示例如下:
查看镜像列表
docker image ls
查看rancher详细信息
docker inspect rancher/rancher:latest
需要创建两个目录,因为rancher是一个容器,如果容器关闭以后,里面某些关键的数据需要持久化的保存下来。所以我们就新建了两个目录,执行这两行命令,为将来的挂载目录作准备。
[root@localhost ~]# mkdir -p /water/runfile/docker_volume/rancher_home/rancher [root@localhost ~]# mkdir -p /water/runfile/docker_volume/rancher_home/auditlog
使用挂载到指定的主机目录上方式进行数据卷持久化同时启动rancher
docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /water/runfile/docker_volume/rancher_home/rancher:/var/lib/rancher -v /water/runfile/docker_volume/rancher_home/auditlog:/var/lib/auditlog --name rancher -e JAVA_OPTS="-Xmx1024m" rancher/rancher
查看容器的进程状态:
docker ps
首次启动docker可能会报相关错误
需要修改文件 vi /usr/lib/sysctl.d/00-system.conf 在最后一行加入
net.ipv4.ip_forward=1
然后重启网络服务
systemctl restart network
再关闭docker中以前的进程即可
docker stop aaas2
docker rm aaas2
查看当前的容器列表
docker container ls
docker run 的 -d 参数标示在后台运行, --restart=always 容器如果异常停止自动重启。-p
8080:8080 把 Rancher 服务器的UI 对外服务(容器内)的端口 8080 ,绑定到到宿主机的
8080 端口。 后面跟的镜像名 rancher/server ,Docker 会首先检查本地有没有这个镜像,
如果没有,Docker 会去 Docker Hub 将这个镜像下载下来,并且启动。
查看日志 日志观测
单独开一个终端,打开 Rancher Server 容器的日志输出,观测:
docker logs -f 93200df98b18
启动好了在你的Master主机上添加相关信息