1. Replace the image source
Backup the default source:
cp /etc/apt/sources.list /etc/apt/sourses.list.bak
edit file:
vim /etc/apt/sources.list
Delete the original content and replace with:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
Update source:
sudo apt-get update sudo apt-get upgrade
The configuration source is very important. Otherwise, after installing various pits, you modify the configuration and cause various problems. It is recommended to reinstall it once.
It is recommended to use the user that git uses to install throughout the process, such as my wangkai, and add sudo in front of the permission command
After configuring the source, install python first
Python 3.8.10 is installed by default
Install Python 3.9 on Ubuntu 22.04 (multiple versions are applicable
2. Docker installation
Uninstall the old version (if any):
apt-get remove docker docker-engine docker.io containerd runc
Set up the repository:
# 安装软件包以允许 apt 通过 HTTPS 使用存储库
apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
# 添加 Docker 的官方 GPG 密钥
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 包索引
apt-get update
Install Docker and scaffolding
apt-get install docker-ce docker-ce-cli containerd.io
Check if the installation is successful:
docker --version
# 启动docker
sudo service docker start
# 查看状态
sudo service docker status
Configure the mirror source:
# 创建文件夹 不先创建保存文件可能提示权限不足(root用户忽略)
mkdir /etc/docker
# 编辑文件
vim /etc/docker/daemon.json
# 文件内容
{
"registry-mirrors": ["https://hub-mirror.c.163.com"]
}
Restart docker:
#重启
sudo service docker restart
#启动
sudo service docker start
@查看状态
sudo service docker status
3. Install docker-compose
sudo mkdir docker-compose
#下载一个对应的docker-compose版本
sudo wget https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-x86_64
#把包移动到指定执行位置
sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
#给权限
sudo chmod +x /usr/local/bin/docker-compose
# 查看安装结果
sudo docker-compose --version
abnormal
#发现docker 启动失败
sudo service docker status
* Docker is not running
How to solve the win10 subsystem can not use systemctl to install ubuntu22.04 with wsl?
quit unbtun
wsl --shutdown
报错wsl ubuntu2022.04 System has not been booted with systemd as init system (PID 1). Can't operate. Fai
In fact, the root cause is that Systemd did not start as follows
How to enable Systemd in Ubuntu/WSL
Or from the releases page of the Github repository . Install a version manually:
Restart (to make sure WSL isn't in use at all), a simple wsl --shutdown might work, but usually doesn't.
Download 1.0.0 (or later) from the link above
Start an administrator PowerShell and:
Add-AppxPackage <path.to>/Microsoft.WSL_1.0.0.0_x64_ARM64.msixbundle
wsl --version # to confirm
To enable, start your Ubuntu (or other Systemd) distribution under WSL (usually wsl ~ will work).
sudo -e /etc/wsl.conf
Add the following:
[boot] systemd=true
Quit Ubuntu and again:
wsl --shutdown
Then restart Ubuntu.
sudo systemctl status
Your Systemd services should be displayed.
ERROR: readlink /var/lib/docker/overlay2: invalid argument
docker system prune --all docker volume prune docker-compose up -d
docker system prune --all
docker volume prune
docker-compose up -d