Skip to content

wsl

启用"Linux 的 Windows 子系统" -> 以管理员身份运行 windows powershell

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

启用虚拟机平台

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

重启系统 & 安装 wsl_update_x64.msi

将 WSL 2 设置为默认版本

wsl --set-default-version 2

关闭子系统

wsl --shutdown

windows 商店安装 Ubuntu

测试

apt update && apt install python3 python3-pip

root 权限

sudo -i

记住密码

sudo echo "leap ALL=(ALL:ALL) NOPASSWD: ALL" >>/etc/sudoers

更换安装源

cp /etc/apt/sources.list /etc/apt/sources.list.bak echo "deb http://mirrors.aliyun.com/ubuntu/ focal main restricted deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted deb http://mirrors.aliyun.com/ubuntu/ focal universe deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe deb http://mirrors.aliyun.com/ubuntu/ focal multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted deb http://mirrors.aliyun.com/ubuntu/ focal-security universe deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse">/etc/apt/sources.list

apt update && apt upgrade -y

安装 docker

curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh service docker start

检查 dockerd 进程启动

service docker status ps aux|grep docker

检查拉取镜像等正常

docker pull busybox docker images

测试

docker swarm init | docker swarm join docker node ls

获取加入 swarm 的 token

docker swarm join-token worker

文件编辑权限问题

sudo chown -R tangdw yunke

docker

systemctl enable docker #开机自启 service docker start #启动 docker service docker stop #停止 docker service docker restart #重启 docker

根据 . 目录下的 dockerfile 构建镜像

sudo docker build --rm -t property-center .

以某镜像起一个容器 --name --net

sudo docker run -P -d --name p1 --mount type=bind,source=$HOME/yunke,target=/workspace/app property-center

映射默认端口 -p :7000

查看容器 ip

sudo docker inspect p1 sudo docker port p1 sudo docker logs p1 sudo docker inspect p1

ssh 安装

Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'

OpenSSH Client

Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

OpenSSH Server

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

启动

Start-Service sshd Set-Service -Name sshd -StartupType 'Automatic' Get-NetFirewallRule -Name ssh New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22