安装Docker
在本地机器上创建docker.sh 脚本,并将如下内容放入脚本中。
#!/bin/bash
echo ~~~~~~~~~~~~~~Start Install~~~~~~~~~~~~~~
#Set up the repository
sudo apt install ca-certificates curl gnupg lsb-release
echo ~~~~~~~~~~~~~~ Add Docker official GPG key~~~~~~~~~~~~~~
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo ~~~~~~~~~~~~~~Set up the repository~~~~~~~~~~~~~~
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
echo ~~~~~~~~~~~~~~Start Install Docker Engine~~~~~~~~~~~~~~
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
echo ~~~~~~~~~~~~~~Configure Docker daemon~~~~~~~~~~~~~~
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://jxmh3d66.mirror.aliyuncs.com"]
}
EOF
echo ~~~~~~~~~~~~~~Set up non-root user~~~~~~~~~~~~~~
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
echo ~~~~~~~~~~~~~~Start Docker service~~~~~~~~~~~~~~
sudo service docker start
进入子系统Ubuntu中,然后切换到docker.sh目录(在子系统访问主系统是挂载在/mnt下,如:子系统访问F盘,就是/mnt/f),然后执行该脚本。
脚本说明:
可以将脚本中的: "https://jxmh3d66.mirror.aliyuncs.com"
替换为其他Docker镜像地址。
参考链接:
■ https://docs.docker.com/engine/install/ubuntu/
■ https://docs.docker.com/engine/install/linux-postinstall/