教你最简单的Docker部署


部署19版的docker

1. 安装依赖包

[root@localhost ~]# yum -y install yum-utils device-mapper-persistent-data lvm2
#yum-utils提供了yum-config-manager
#device mapper存储驱动程序需要device-mapper-persistent-data和lvm2
#Device Mapper是Linux2.6 内核中支持逻辑卷管理的通用设备映射机制,它为实现用于存储资源管理的块设备驱动提供了一个高度模块化的内核架构。

2. 设置阿里云镜像源

[root@localhost ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  docker-ce.repo

3. 安装Docker-CE

[root@localhost ~]# yum -y install docker-ce
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker

4. 镜像加速

[root@localhost ~]# cd /etc/docker/
[root@localhost docker]# ls
key.json
[root@localhost docker]# tee /etc/docker/daemon.json <<-'EOF'
> {
>   "registry-mirrors": ["https://jih246wn.mirror.aliyuncs.com"]
> }
> EOF
{
  "registry-mirrors": ["https://jih246wn.mirror.aliyuncs.com"]
}
[root@localhost docker]# ls
daemon.json  key.json
#每个人都有自己的镜像加速地址
[root@localhost docker]# systemctl daemon-reload 
[root@localhost docker]# systemctl restart docker

5. 网络优化

[root@localhost docker]# vim /etc/sysctl.conf
net.ipv4.ip_forward=1
[root@localhost docker]# sysctl -p
net.ipv4.ip_forward = 1
[root@localhost docker]# systemctl restart network
[root@localhost docker]# systemctl restart docker
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值