Fix WSL2 Connection Issue to Docker Daemon | Notes

abhiweb

Kumar Abhishek

Posted on July 17, 2021

Fix WSL2 Connection Issue to Docker Daemon | Notes

Recently while setting up docker for Hyperledger in WSL2, I got the following error:

====> hyperledger/fabric-peer:2.3.2
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
Enter fullscreen mode Exit fullscreen mode

After a quick research, it turns out that if you are upgrading from WSL to WSL2, Windows leaves behind a few legacy settings from WSL that causes this issue.

Here is the fix that worked for me:

Step 1: Check if you have the same issue §

  1. In WSL2 terminal, run the command: docker info | head -15
  2. You should see the following error: ERROR: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?

Step 2: Check if the fix works for you §

  1. Run the command: unset DOCKER_HOST
  2. Follow the previous step again. The error should be gone now.

Step 3: Make the fix permanent §

  1. Edit the .bashrc script with: vi ~/.bashrc
  2. Search for the line with DOCKER_HOST and comment it out like this: # export DOCKER_HOST=tcp://localhost:2375
  3. Save the file and reload the terminal settings with source ~/.bashrc

Read on abhi.page

💖 💪 🙅 🚩
abhiweb
Kumar Abhishek

Posted on July 17, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related