1.安装docker
1)更新yum为最新
yum update
2)安装docker
curl -fsSL get.docker.com | sh
如果中间出现网络问题之类的导致一些文件无法下载,要检查是否是前面的DNS或者源没配置好
2.开启远程访问
添加配置信息
vi /lib/systemd/system/docker.service
[root@localhost system]# vi docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by dockerExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
-H tcp://0.0.0.0:7777
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
在文件中的ExecStart中添加添加“-H tcp://0.0.0.0:7777 ” ,端口根据实际情况处理
3.启动docker服务,并设置为启动项
1)启动服务
service docker start
2)开机启动项
chkconfig docker on
4.下载rancher
1)下载相关镜像,当前使用2.x版本rancher/rancher
docker pull rancher/rancher:stable
2)docker中运行rancher
docker run -d -v /data/docker/rancher-server/var/lib/rancher/:/var/lib/rancher/ --restart=unless-stopped --name rancher-server -p 9443:443 rancher/rancher:stable
-p 后面接的端口号,指的是“对外端口:内部端口”
3)查看rancher容器的编号
docker ps | grep "rancher/rancher:stable"
5.配置rancher
1)安全可以给Rancher配置登录账号(选择 系统管理 --》访问控制 --》LOCAL)
2)配置主机
基础架构 --》主机 --》添加主机 --》Custom