Windows10 子系统Ubuntu安装Docker详细步骤

Windows 10 子系统安装docker,并解决Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 问题。

  1. 搜索框中搜索开发者设置 image.png

  2. windows 设置打开开发者选项 image.png

  3. 搜索框中搜索windows功能 image.png

  4. 勾选使用于Linux的Windwos子系统 image.png

  5. 安装 Docker Desktop for Windows

    下载地址:https://www.docker.com/products/docker-desktop

    安装成功后打开 Expose daemon on tcp://localhost:2375 without TLS image.png

  6. 在Microsoft Store中搜索Ubuntu,然后安装就行 image.png

  7. Ubuntu安装成功后打开(第一次打开需要设置用户名和密码) image.png

  8. 然后依次执行以下命令:

    Docker 官网安装步骤: https://docs.docker.com/engine/install/ubuntu/ ,不想看官网的直接按照以下命令执行即可

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    $ sudo apt-get update
    $ sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
    $ 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"
    $ sudo apt-get update
    $ sudo apt-get install docker-ce
    $ docker -H localhost:2375 images
    $ export DOCKER_HOST=localhost:2375
    $ echo "export DOCKER_HOST=localhost:2375" >> ~/.bashrc</pre>

到此docker就安装就成功了,可以愉快的玩耍了。