docker安装

docker安装

基础环境

#关闭防火墙、核心防护,挂载系统镜像

systemctl stop firewalld
setenforce 0
mount /dev/sr0 /mnt

安装wget工具

yum -y install wget

手动安装

安装依赖软件

yum install -y yum-utils device-mapper-persistent-data lvm2

#yum-utils 提供了 yum-config-manager工具

#device mapper 存储驱动程序需要 device-mapper-persistent-data 和 lvm2

设置docker仓库

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安装 Docker Engine-Community

配置阿里在线源(安装时需要依赖工具通过在线源下载)

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache

安装最新版本

yum install docker-ce docker-ce-cli containerd.io

在这里插入图片描述

安装特定版本

yum list docker-ce --showduplicates | sort -r  #列出所有版本并查看
#安装时指定版本
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
#通过其完整的软件包名称安装特定版本,该软件包名称是软件包名称(docker-ce)加上版本字符串(第二列),从第一个冒号(:)一直到第一个连字符,并用连字符(-)分隔。例如:docker-ce-18.09.1
systemctl start docker   #启动docker

docker run hello-world #检测

在这里插入图片描述

权限提示

安装完成后,出现以下提示

在这里插入图片描述

此提示是为了告知如何给予非root用户权限使用docker全部操作

sudo usermod -aG docker xx #将xx加入docker组内,即给予xx权限使用docker全部操作

自动安装

配置阿里在线源

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

使用官方脚本自动安装

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

使用一键安装命令

curl -sSL https://get.daocloud.io/docker | sh
systemctl start docker   #启动docker

docker run hello-world #检测

镜像加速

当从dockerhub拉取镜像时,有时会难以拉取,可以使用加速服务,尽可能避免

国内的加速服务:

科大镜像:https://docker.mirrors.ustc.edu.cn/
网易:https://hub-mirror.c.163.com/
阿里云:https://xxxxxx.mirror.aliyuncs.com #xxxxxx为用户标识使用阿里云加速需要预先申请
七牛云加速器:https://reg-mirror.qiniu.com
 #xxxxxx为用户标识使用阿里云加速需要预先申请,获取阿里云镜像地址:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors

可以多添加几个镜像,如果一个无法使用,可以自动切换


配置

docker启动后

vi /etc/docker/daemon.json
{"registry-mirrors":["https://reg-mirror.qiniu.com/"]}
{"registry-mirrors":["https://hub-mirror.c.163.com/"]}
{"registry-mirrors":["https://docker.mirrors.ustc.edu.cn/"]}
{"registry-mirrors":["https:///5mrjn3lu.mirror.aliyuncs.com"]}	

systemctl daemon-reload
systemctl restart docker

开开启路由转发

docker内运行的容器与外部通信时需要

echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p
systemctl restart network

t docker


开开启路由转发

docker内运行的容器与外部通信时需要

echo “net.ipv4.ip_forward=1” >> /etc/sysctl.conf
sysctl -p
systemctl restart network


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值