首先参考安装 WSL | Microsoft Docs, 若是版本未达到要求参考旧版 WSL 的手动安装步骤 | Microsoft Docs ,第6步执行完之后,执行以下 *** 作:
然后Ubuntu上安装Docker CE
1.先卸载旧版本的docker
$ sudo apt-get remove docker docker-engine docker.io containerd runc
用资源库安装
2.Update the apt package index and install packages to allow apt to use a repository over HTTPS:
$ sudo apt-get update
$ sudo apt-get install
apt-transport-https
ca-certificates
curl
gnupg-agent
software-properties-common
3.Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository
"deb [arch=amd64] https://download.docker.com/linux/ubuntu
$(lsb_release -cs)
stable"
4.INSTALL DOCKER ENGINE
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
如果要安装特定版本的docker-ce,用如下步骤:
$ apt-cache madison docker-ce
$ sudo apt-get install docker-ce=
5.Verify that Docker Engine is installed correctly by running the hello-world image. (需要docker desktop处于启动状态)
$ sudo docker run hello-world
启动Docker Desktop发生错误System.IO.IOException:
The process cannot access the file 'C:UsersxxxxAppDataLocalDockervm-configconfig.iso' because it is being used by another process.
解决办法:进Hyper-V Manager,关闭DockerDesktopVM
授于当前用户以root权限运行Docker CLI
$ sudo usermod -aG docker $USER
安装Docker Compose
# Install Python and PIP.
$ sudo apt-get install -y python3 python3-pip
# Install Docker Compose into your user's home directory.
$ pip3 install --user docker-compose
连接Docker daemon
最关键的一行命令,打开Bash:
$ echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc && source ~/.bashrc
验证Docker启动成功:(先执行unset DOCKER_HOST)
$ docker info
$ docker-compose --version
$ docker run hello-world
如果docker info失败,报如下错误:
ERROR: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
执行unset DOCKER_HOST,然后再跑docker info
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)