0


Ubuntu 安装 Docker 操作步骤

Ubuntu 安装 Docker 操作步骤
出处:https://mp.weixin.qq.com/s/iRAS3ztfZF2P8GX6lkX8cQ

1.开启密码登陆,关闭ssh的dns解析
2.禁用自动更行
3.启用指定网卡,修改IP
4.设置主机名称
5.修改时区
6.关闭selinux
7.关闭防火墙
8.关闭swap
9.挂载扩容磁盘
10.安装指定版本Docker
1.sshd 设置 开启22端口,开启密码登陆,关闭dns解析
sed -i ‘s/#Port 22/Port 22/g’ /etc/ssh/sshd_config &&
sed -i ‘s/#PasswordAuthentication yes/PasswordAuthentication yes/g’ /etc/ssh/sshd_config &&
sed -i ‘s/#UseDNS no/UseDNS no/g’ /etc/ssh/sshd_config &&
systemctl restart sshd
2.禁用自动更新
sed -i ‘s/“1”/“0”/g’ /etc/apt/apt.conf.d/10periodic &&
sed -i ‘s/“1”/“0”/g’ /etc/apt/apt.conf.d/20auto-upgrades &&
cat /etc/apt/apt.conf.d/10periodic &&
cat /etc/apt/apt.conf.d/20auto-upgrades &&
reboot
3.启用指定网卡,修改IP,公有云下可以忽略
sed -i ‘s/192.168.100.185/192.168.100.186/g’ /etc/netplan/00-installer-config.yaml
4.设置主机名称
hostnamectl --static set-hostname 192-168-100-186
5.修改时区,修改时间
timedatectl set-timezone Asia/Shanghai
6.关闭selinux
ubuntu 20.x 默认关闭
7.关闭防火墙
ufw disable &&
ufw status verbose
8.关闭swap
swapoff -a && sysctl -w vm.swappiness=0 &&
sed -ri ‘/[#]*swap/s@^@#@’ /etc/fstab

格式化残存的 swap

mkfs.xfs -f /dev/sda3
9.挂载扩容磁盘 /dev/sdb
#格式化
mkfs.xfs /dev/sdb

#挂载
mkdir -p /data
mount /dev/sdb /data

#开机自动挂载 /etc/fstab
echo ‘/dev/sdb /data xfs noatime 0 0’ >> /etc/fstab
x.更新组件
apt update -y &&
apt upgrade -y &&
apt install -y policycoreutils &&
apt install -y net-tools &&
apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
10.安装指定版本Docker
#创建/data/与docker目录
mkdir -p /data/docker

#将docker默认安装目录映射至
ln -s /data/docker /var/lib/docker

#rancher2 kubernetes 额外需要的目录
mkdir -p /data/kubelet && ln -s /data/kubelet /var/lib/kubelet
mkdir -p /data/rancher && ln -s /data/rancher /var/lib/rancher
mkdir -p /data/pods && ln -s /data/pods /var/log/pods
下载离线安装包并安装
mkdir -p /data/package && cd /data/package &&
wget https://docker-snake.cn-bj.ufileos.com/docker/ubuntu/20.x/containerd.io_1.6.24-1_amd64.deb &&
wget https://docker-snake.cn-bj.ufileos.com/docker/ubuntu/20.x/docker-buildx-plugin_0.11.2-1_ubuntu.20.04_focal_amd64.deb &&
wget https://docker-snake.cn-bj.ufileos.com/docker/ubuntu/20.x/docker-ce-cli_24.0.6-1_ubuntu.20.04_focal_amd64.deb &&
wget https://docker-snake.cn-bj.ufileos.com/docker/ubuntu/20.x/docker-ce-rootless-extras_24.0.6-1_ubuntu.20.04_focal_amd64.deb &&
wget https://docker-snake.cn-bj.ufileos.com/docker/ubuntu/20.x/docker-ce_24.0.6-1_ubuntu.20.04_focal_amd64.deb &&
wget https://docker-snake.cn-bj.ufileos.com/docker/ubuntu/20.x/docker-compose-plugin_2.21.0-1_ubuntu.20.04_focal_amd64.deb &&
dpkg -i --force-depends *.deb
配置DNS
sed -i ‘s/#DNS=/DNS=8.8.8.8/g’ /etc/systemd/resolved.conf &&
systemctl restart systemd-resolved &&
systemctl enable systemd-resolved &&
mv /etc/resolv.conf /etc/resolv.conf.bak &&
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf &&
cat /etc/systemd/resolved.conf &&
cat /etc/resolv.conf
配置docker选项
tee /etc/docker/daemon.conf <<-‘EOF’
{
“registry-mirrors”:[
https://registry.cn-hangzhou.aliyuncs.com/”
],
“log-driver”:“json-file”,
“log-opts”:{
“max-size”:“5m”
},
“storage-driver”:“overlay2”,
“storage-opts”:[
“overlay2.override_kernel_check=true”
]
}
EOF
文档预先步骤下载离线包
apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

apt install -y aptitude
aptitude --download-only install -y docker-ce docker-ce-cli containerd.io &&
cd /var/cache/apt/archives &&
ls -lh

dpkg -i --force-depends *.deb

标签: ubuntu docker 数据库

本文转载自: https://blog.csdn.net/weixin_44770477/article/details/141353566
版权归原作者 柯基宝宝的小屁屁-测试-某书同名 所有, 如有侵权,请联系我们删除。

“Ubuntu 安装 Docker 操作步骤”的评论:

还没有评论