一、镜像下载
下载 Ubuntu Server 22.04 的镜像
官网地址: https://ubuntu.com/server
二、创建虚拟机
(1)选择语言 English
(2)设置静态 ip
(3)配置镜像地址
(4)开启 SSH
三、基本配置
SSH 配置
配置允许 root 用户登录 /etc/ssh/sshd_config
设置项目 PermitRootLogin yes,然后重启 ssh 服务 sudo service ssh restart
设置 root 密码
sudo passwd root
设置镜像源
设置为阿里云镜像 /etc/apt/source.list
deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
更新 apt update
安装网络工具 apt install net-tools
配置静态 ip
设置静态 ip /etc/netplan/00-installer-config.yam
network:
ethernets:
ens33:
addresses:
- 192.168.81.20/24
nameservers:
addresses:
- 8.8.8.8
- 114.114.114.114
search: []
routes:
- to: default
via: 192.168.81.1
version: 2
四、安装 Docker
(1)更新依赖包
sudo apt update
sudo apt upgrade
(2)安装 Docker 依赖工具
apt-get install ca-certificates curl gnupg lsb-release
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
(3)添加Docker官方GPG密钥
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
(4)添加Docker软件源
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
更新依赖包
sudo apt update
sudo apt upgrade
(5)安装 Docker
apt-get install docker-ce docker-ce-cli containerd.io
(6)运行 Docker
systemctl start docker
(7)验证是否成功
sudo docker version
systemctl status docker
sudo docker run hello-world
sudo docker images
标签:http,aliyun,mirrors,Ubuntu,apt,22.4,ubuntu,com,搭建
From: https://www.cnblogs.com/zhxish/p/18130288