树莓派安装UbuntuServer

系统准备

安装树莓派Imager

downloads.raspberrypi.org/imager/imag…

准备系统镜像

也可以自己下载其他镜像,或者直接在Imager中选择镜像,自行下载(速度较慢)

Ubuntu系统镜像下载

烧录系统

  • 打开Imager
  • 选择使用自定义镜像
  • 找到刚下载好的镜像
  • 选择SD卡
  • 烧录即可

系统设置

开机登录

默认账号为:ubuntu,默认密码为:passwd

配网

检查默认的网络配置文件,默认为50-cloud-init.yaml

cd /etc/netplan
ls
# 50-cloud-init.yaml

编辑配置文件

sudo vim 50-cloud-init.yaml

添加如下配置信息,wifi可以配置多条(如需配置静态IP请查看其他设置)

# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
eth0:
dhcp4: true
optional: true
version: 2
wifis:
wlan0:
dhcp4: true
access-points:
"wifi名称1":
password: "wifi密码1"
"wifi名称2":
password: "wifi密码2"

检查配置是否可行

sudo netplan try #如果无其他错误,此处提示按ENTER
sudo netplan generate #生成配置文件
sudo netplan apply #应用配置文件
ifconfig #查看IP地址

apt换源

# 备份就镜像源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 替换新镜像源
sudo sed -i -r 's#http://(archive|security|ports).ubuntu.com#https://mirrors.aliyun.com#g' /etc/apt/sources.list && sudo apt-get update

安装Docker

脚本自动安装

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

apt安装

安装依赖

sudo apt update sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

导入源仓库GPG key

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

添加Docker APT 软件源

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

安装docker最新版本

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io

Docker允许非root用户使用

sudo usermod -aG docker $USER

sudo usermod -aG docker $USER

Docker配置镜像加速

sudo docker info #查看镜像信息
sudo vim /etc/docker/daemon.json #编辑配置信息,填入以下信息
{
"registry-mirrors": ["https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://registry.docker-cn.com"]
}
# 重载配置信息
sudo systemctl daemon-reload
sudo systemctl restart docker