前言:在安装docker之前先确保你有centos镜像,因为容器是需要在centos里面进行安装的,我这里只讲linux如何安全dokcer,windons的自己去其他地方查找资料!
不懂可以在评论区留言
⭐docker如何在centos7.6安装⭐
1:关闭并禁用防火墙,并查询防火墙是否关闭。
systemctl stop firewalld //关闭防火墙
systemctl disable firewalld //禁用防火墙服务
systemctl status firewalld //检查状态
2:修改/etc/selinux目录中的config文件,设置SELINUX为disabled后,保存并退出文件(重启生效)。
vi /etc/selinux/config //进入这个目录
设置SELINUX为disabled
重启后生效
reboot
3:修改网卡配置文件ip为192.168.200.5/24,DNS为114.114.114.114
注意:这里配置的ip地址必须要和你的虚拟机处在同网段
vi /etc/sysconfig/network-scripts/ifcfg-ens33 //进入网卡
systemctl restart network //重启网卡
4:使用root权限登录CentOS 7,利用yum命令将yum包更新到最新版本。
yum update yum //更新yum工具本身
yum update //更新已经安装的包到最新
reboot //更新后重启系统
5:配置时间同步,可以选用公网ntpd服务器或者自建ntpd服务,本任务使用阿里云的时间服务器。
先安装好ntpd服务
yum install ntp ntpdate -y
使用阿里云的时间服务器
ntpdate ntp1.aliyun.com
6:如果安装过旧版本,则需卸载已安装的旧版本。反之,此步骤可以略过。
yum remove docker docker-common docker-selinux docker-engine
7:安装必需的软件包。
yum install -y yum-utils device-mapper-persistent-data lvm2
8:设置docker源。
yum-config-manager --add-repo
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
9:安装Docker。
更新并安装Dcker-ce(如果要下载指定的版本docker-ce-20.10.15)
yum makecache fast
yum -y install docker-ce
10:启动Docker并设置开机自启动。
service docker start //开启服务
systemctl enable docker //开机自启动
11:运行nginx镜像来测试是否安装成功。
docker pull nginx
12.运行测试是否安装成功
docker run -dit -p 80:80 nginx:latest
docker ps //确定容器是否正在运行
百度访问自己虚拟机的IP地址(出现这个表示成功)