ubuntu部署Docker服务


目录

  1. 部署docker服务准备
  • kernetl 内核3.0及以上
  • 开启IP转发功能
  • 关闭swap
  1. docker服务安装
  • 安装服务
  • 配置镜像仓库

说明:在Master,node1,node2,node3上都需要做配置

环境准备

  • 系统: Ubuntu20.04
root@k8s:~# uname -r
5.4.0-65-generic
root@k8s:~#
  • 开启IP转发
root@k8s:~# sysctl -w net.ipv4.ip_forward=1
或者
root@k8s:~# sysctl -w net.ipv4.ip_forward=1
验证:
root@k8s:~# sysctl -p
net.ipv4.ip_forward = 1
root@k8s:~#
  • 关闭swap交换分区
#:swapoff -a 
注释/etc/fstab中swap 部分
  • 修改服务器时区为Asia/Shanghai
timedatectl set-timezone Asia/Shanghai
  • 重启日志服务: rsyslog
systemctl restart rsyslog
  • 关闭服务器休眠功能
sudo systemctl mask sleep.target suspend.target hibernate.target hybridsleep.target

  • 开启bridge跟踪功能模块,加载br_netfilter模块
cat <
  • 设置rp_fileter
root@k8s:~# cat /etc/sysctl.d/10-network-security.conf 

# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks.
net.ipv4.conf.default.rp_filter=1
net.ipv4.conf.all.rp_filter=1
root@k8s:~#

docker服务安装

  • 安装服务
    直接安装:docker.io 默认为Version: 19.03.08
sudo apt list | grep docker
所有节点上安装docker
sudo apt install docker.io -y
服务开机启动
systemctl enable docker
  • 配置镜像仓库
    参考