Windows使用WSL2及docker(Ubuntu22.04 LTS)

WSL2初始化

1.换源

#1
cp /etc/apt/sources.list /etc/apt/sources.list.bak

#2
vim /etc/apt/sources.list
# 清空原源并替换成以下源
# 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 multiverse

#3
apt update

2.安装zsh

#1
apt install zsh

#2
vim /etc/resolv.conf
nameserver 8.8.8.8 #粘贴此行

#3
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

#4
# 自动补全
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
# 语法高亮
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

#5
vim ~/.zshrc
# 覆盖原内容
plugins=(
  git
  zsh-autosuggestions
  docker
  docker-compose
  kind
  kubectl
)

#6
source ~/.zshrc 

安装docker

1. 添加docker源

#1
apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

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

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

2.下载docker

#1
apt update

#2
apt install docker-ce docker-ce-cli containerd.io

3.docker镜像换源

#1
vim /etc/docker/daemon.json

#2
#添加源
{
    "registry-mirrors": ["https://kn0t2bca.mirror.aliyuncs.com"]
}

4.启动docker

#1
update-alternatives --config iptables
#then select 1            /usr/sbin/iptables-legacy   10        manual mode

#2
service docker start
posted @ 2024-05-03 15:28  临冬城城主  阅读(759)  评论(0编辑  收藏  举报