Cannot connect to the Docker daemon on bash on Ubuntu windows

前端 未结 7 1268
时光说笑
时光说笑 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条回答
  •  孤城傲影
    2021-01-30 13:43

    In addition to what was already said, I would like to share with you some issues that I had while setting up and the solutions that eventually allowed me to start working with a WSL2/Docker Desktop combo. This is not a complete guide, just another source of troubleshooting!

    My goal was

    1. Start Experimenting with Docker.
    2. Setup my environment so it is as recommended and most comfortable.
    3. Basically to be able to work in a Linux Context while working with Docker Desktop.

    How I went about it

    1. I upgraded my PC from Win 10 Home to Win 10 Pro, to avoid various issues I read that people were having with the Home edition.
    2. I had Docker Toolbox installed and then deleted it as well as the Oracle VM install I had on my PC. I had various small issues, read online that it's best to remove Oracle VM as well.
    3. I installed Docker Desktop.

    Issues and their solutions

      1. A few of the environment variables from the old Docker Tools installation remained. This caused Docker Desktop to misbehave.
      Solution: I deleted all of them. (Any variable name that mentioned Docker)
      2. When trying to connect to Docker on localhost:2375 via Ubuntu WSL2 got the famous "...is docker even running" error. Worth mentioning that on cmd docker was working properly at this stage.
      Solution:
        - Purge a previous installation of Docker I had on my Ubuntu WSL2.
        - Make sure to delete all and any environment variables that mentioned Docker on my ubuntu WSL2.
        - Stop Hyper-v, Rebooted, Started Hyper-V Rebooted on Windows.
        - Install the latest version of Docker via `apt-get`.

    Now running on Ubuntu WSL2 "docker context ls" to check my setup should result in:

    NAME        DESCRIPTION                               DOCKER ENDPOINT               KUBERNETES ENDPOINT   ORCHESTRATOR
    default *   Current DOCKER_HOST based configuration   unix:///var/run/docker.sock                         swarm
    

    Running Docker Info from Ubuntu WSL2:

    Client:
     Context:    default
     Debug Mode: false
     Plugins:
      app: Docker App (Docker Inc., v0.9.1-beta3)
      buildx: Build with BuildKit (Docker Inc., v0.5.0-docker)
      scan: Docker Scan (Docker Inc., v0.5.0)
    
    Server:
     Containers: 3
      Running: 0
      Paused: 0
      Stopped: 3
     Images: 3...
    

提交回复
热议问题