Cannot connect to the Docker daemon on bash on Ubuntu windows

前端 未结 7 1273
时光说笑
时光说笑 2021-01-30 12:53

I am able to install docker, docker-compose and docker-machine

However when I try to run

root@DESKTOP-51NFMIM:~# docker ps
Cannot connect to the Docker d         


        
7条回答
  •  -上瘾入骨i
    2021-01-30 13:28

    The Docker client and server can now be installed and run purely in WSL without Docker Desktop for Windows if you are running Windows 10 version 1803 or greater. I have it working on the following WSL:

    OS: Ubuntu 18.04 bionic [Ubuntu on Windows 10]
    Kernel: x86_64 Linux 4.4.0-17763-Microsoft
    

    Simply follow the same instructions to install on Ubuntu but make sure to choose a specific version to install. Presently, version 18.06.1~ce~3-0~ubuntu works fine but later versions up to 5:18.09.6~3-0~ubuntu-bionic have an issue with starting up a container. The following command will install the latest working version:

    apt-get install docker-ce=18.06.1~ce~3-0~ubuntu
    

    To get the Docker server running in WSL after installation, close all open terminals and start a new Ubuntu terminal as administrator (i.e., right click the Ubuntu shortcut and click 'Run as administrator'). Finally, run the following commands:

    sudo cgroupfs-mount
    sudo service docker start
    

    sudo service docker start will have to be run each time Windows is rebooted. However, if you wish to avoid that, you can automate it using the Task Scheduler and a shell script by following the steps listed here.

    Test that everything is working using:

    docker run hello-world
    

    Reference: https://medium.com/faun/docker-running-seamlessly-in-windows-subsystem-linux-6ef8412377aa

提交回复
热议问题