在开始之前,window 要开启子系统
1 安装WSL2
wsl --set-version Ubuntu-18.04 2
如果报 login的错误
运行gpupdate /force
打开ubuntu
2安装dockers
sudo apt update
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
gpg: WARNING: unsafe ownership on homedir '/home/roc/.gnupg'
File '/usr/share/keyrings/docker-archive-keyring.gpg' exists. Overwrite? (y/N) y
curl https://get.docker.com | sh
sudo curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
启动 docker
sudo service docker start
查看状态
sudo service docker status
-----------其他---------------------------------------------------------
启动 docker
sudo service docker start
查看状态
sudo service docker status
构建容器
docker-compose up -d --build
Xdebug 配置
运行tnc host.docker.internal -p 9003 获取SourceAddress ,更新xdebug.client_host
vscode中 launch.json 添加
"
{
""name"": ""Listen for XDebug"",
""type"": ""php"",
""request"": ""launch"",
""port"": 9003,
""pathMappings"":{
""/var/www/html/"":""${workspaceFolder}/""
}
},"
本地ubuntu 和 容器的DNS 配置
设置系统DNS服务器,确保可以使用网络。据说是google得
把以前的link文件删除
sudo rm /etc/resolv.conf
重新生成文件并把命令写入
sudo echo "nameserver 8.8.8.8" > /etc/resolv.conf
查看编辑是否正确
sudo cat /etc/resolv.conf
把DNS服务器IP也设置下
cmd命令行
敲ipconfig /all 找到 DNS Servers
把值添加到
sudo vi/etc/resolv.conf