Environment
Windows version and build Version 2004 (OS Build 19037.1)
Docker Edge version 2.1.6.1
Ubuntu 18.04 on WSL 2
Current setup and status:
docker installed on windows
created aliases for docker, docker-compose, docker-credential-desktop, etc ...
Running commands such as docker build, docker ps, docker pull, docker images all work fine. Now I would like push an image and so of course I have to login first.
Problem: logging into docker hub.
I run docker login in the WSL terminal
I put in my username and password
I get the following error
Error saving credentials: error storing credentials - err: exec: "docker-credential-desktop": executable file not found in %PATH
%, out: ``
What I've tried so far
docker login from powershell works fine. So I created a symbolic link between /mnt/c/Users/<winusername>/.docker and /home/<wslusername>/.docker. The equivalent works fine for .aws, but for .docker it was not able to share or even acknowledge the credentials, so it asked again for the user and password and threw the same error as above.
This worked for me,
sudo ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker-credential-desktop.exe /usr/bin/docker-credential-desktop.exe
Linking the executable from windows path to linux path or you can add the windows PATH on you linux PATH.
Refer: https://github.com/docker/for-win/issues/6652
Update Feb 2021
This is all much simpler now. If you are using WSL2 on a recent release of Windows, just install docker on the Windows side and ensure to configurations:
In General: us the WSL 2 based engine
In Resource/WSL Integration: enable integration with your default WSL distro
You will have to restart docker. Once it is done, everything works transparently.
Below here can be ignored
It turns out that the integration between Docker and WSL is better than I thought. Though it could have been better documented. I was going to change tack and try to install docker in the WSL. So I got rid of all the aliases and restarted my session. Lo and behold, when I ran docker there was still something running.
This is because the edge version of docker create the appropriate symbolic links and now I login into docker hub without any problem.
Related
I am new to Docker and after writing docker version in cmd I got this error,
error during connect: This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/version": open //./pipe/docker_engine: The system cannot find the file specified.
The following steps solved this problem:
Open cmd as administrator
Launch command: "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon
some times docker might be disabled from starting on boot or login so in the windows search bar or when clicking the WinKey and starting to type Dock... like showen in the picture below, Then press Enter to start the Docker Daemon
Try running dockerd in a separate terminal and then try running this command.
To avoid doing this every time you can go to services -> find Docker -> select Startup Type as Automatic (Delayed) and reboot the machine.
Simple Solution: Just open Powershell and type dockerd which will start the daemon and you shall be able to use the docker now without errors.
On Windows, reason behind this issue is that Docker is not started. I tried couple of solution provided on multiple online portal to start it. What worked for me is:
In Docker Desktop if you are already logged in as a user, logout from there
Again login to docker desktop with docker account
When we login to docker account, it internally triggers the restart. So resulting if it's not started, it will start the docker for us.
I had this, but when I used a command shell elevated to Administrator, docker version was fine.
This error may indicate that the docker daemon is not running.: Get "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json": open //./pipe/docker_engine: The system cannot find the file specified.
this error in windows 10
step 1
pls install (https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package) Download the latest package:
this link WSL2 Linux kernel update package for x64 machines
then restart then automatically running
In my case,
I download the this github repo.MaxySpark
Closed all the application related to docker.
1.Click on docker.reg file in the downloaded repo.
2.Click on yes->yes->ok to merge.
3.Again open the Docker Toolbox and run docker run hello-world
Open cmd as administrator
Launch command: C:\Program Files\Docker\Docker\DockerCli.exe -SwitchDaemon
It simply means that your docker application is not running or you have not logged in to docker application, or docker desktop service is not running .
1: Just open Docker desktop application, login with docker credentials.
2: if already logged in and still getting this error, go to windows + r ==> and type 'services.msc', and restart the docker desktop service.
All done.
It can be kernel problem:
You need to update WSL2 Linux kernel update package for x64 machines
Follow this tutorial:
https://linuxhint.com/resolve-docker-daemon-not-running/
and before execute "docker run hello-world" command, dont forget restart docker
https://learn.microsoft.com/en-us/windows/wsl/install-manual
I am not able to start the Docker container in Microsoft Windows 10 profession. As I found the cause of this error is due to the docker engine is failing to start.
After installing docker I am able to run only the docker version command.
-> docker --version
As I found the error which is showing docker daemon is not running in windows while running any other docker commands on CMD.
I also enabled (checked) the Hyper-V option in "Turn Windows features on or off" in the Control panel -> Programs -> Turn Windows features on or off.
The error is related to the daemon part:
In the default daemon configuration on Windows, the docker client must be run elevated to connect.
We can switch the Docker daemon as an elevated user in order to run the docker daemon in the Windows professional:
Run below command with Windows Powershell as administrator:
Run the PowerShell command: -
& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon
OR
You can run the below command on CMD as administrator:
Run the CMD command: -
"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon
My Docker Desktop failed to start after I forced it to exit while updating (it stuck during the update that's why I had to do it). No solution on the Internet helped me until I ran into this Powershell command:
wsl -l -v
It listed the following:
* Ubuntu-18.04 Stopped 2
docker-desktop Uninstalling 2
docker-desktop-data Stopped 2
It kept saying "Uninstalling" even after rebooting the whole system.
What I did was:
wsl -t docker-desktop
It terminated docker-desktop and made the problem gone.
delete %appdata%\Docker\settings.json and let Docker to create a new one
You should check WSL:
Execute "wsl -l -v" at the command prompt.
If the result is like this:
Then execute "wsl --shutdown" on the command line.
Then execute "wsl -l -v", you will see:
Then start Docker Desktop.
This solved my problem.
Make sure to download the Linux Kernel Update Package and then try restarting Docker Desktop.
Download from here
Just share my experience how I solved the problem with "docker failed to start" or similar problem. I found some mess with my Win10 Home edition, despite the fact that all checkes regarding Hyper-v, wsl and others passed I got failed to start docker engine. So, I tried to install one of the old version (4.4.4), not the newest one. An voila it installed wsl2 and started without any problems!
Hope this could help someone who's tried all solutions (for example, deletion of the %appdata%\docker folders) :)
I was getting the same exact issue and a solution was provided from thread The attempted operation is not supported for the type of object referenced." error after Windows Update fixed my problem. I had tried everything before this solution. To keep it simple just follow the below steps -
Copy below snippet
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2\Parameters\AppId_Catalog\0408F7A3]
"AppFullPath"="C:\Windows\System32\wsl.exe"
"PermittedLspCategories"=dword:80000000
Save it as a file wsl.reg
Execute the file to update the wsl registry
restart docker desktop
these steps are basically done to do some changes in the registry of wsl distribution that is installed standalone or by docker.
Using PowerShell gave me a right direction. All restarts and re-install with deletion didn't work.
wsl -l -v showed list of three processes but wsl -t docker-desktop responded with "There is no distribution with the supplied name." only. wsl --shutdown either didn't work.
Solution is next door wsl --unregister docker-desktop . After this all went fine.
I ran the following command which resolved the issue for me.
wsl --unregister docker-desktop
Please make sure your OS type requires WSL or Hyper-V to run docker as per this official link 👉 https://docs.docker.com/desktop/install/windows-install/
For my case, I am using Windows 11 Home OS, and it requires WSL (Windows Subsystem for Linux) to run docker. So that I installed WSL on my system.
Follow this link to install WSL 👉 https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package
After that restart your system, then open docker (It may take up to 10 secs to start)
Hope it may solve your issue✌️
I installed docker and downloaded an ubuntu distro to run with laravel sail,planing to use swoole php,and made it default,also made wsl version to 2
with docker-compose.yml ready from laravel sail docker-compose.yml:
but every time I try to run the sail up cmd,it gives me this error " Unsupported operating system [MINGW64_NT-10.0]. Laravel Sail supports macOS, Linux, and Windows (WSL2)."
any ideas how to fix this ?
If you are using windows follow these steps.
Make sure ubuntu and WSL 2 is installed, you can follow the instructions here
After successful installation of ubuntu, your file system now shares the same file system with your ubuntu, this means if you want to run ubuntu commands on a folder path you have to open the corresponding terminal. If you are using Visual Studio Code, you can select the corresponding ubuntu terminal for the file directory by selecting ubuntu as the new terminal, it will open the Ubuntu terminal on the current path.
You can run ./vendor/bin/sail up. Make Sure you are running the command from your project folder in Ubuntu. Usually the folder is always in /mnt/c/users/path/to/project.
If you see docker not running. Open your docker desktop, go to setting, under resources, select WSL and enable integration with your ubuntu
Restart your terminal, and run the command again. Don't forget under you Ubuntu file system which is usually in /mnt/c/users/path-to-laravel-project.
you should see the following for the first time. Note the folder path highlighted.
One last thing, in order to access your laravel app on your localhost, you have to access the WSL IP address that connects to Ubuntu. use the following command. wsl hostname -i it outputs an IP address like , Note! your IP address may be different. Navigate to the IP address on default port 80 and you should see.
I wish you a successful project. Enjoy!!
You need to run the sail up command from inside your WSL2 Ubuntu Image not directly from your terminal. Once you do that it should work ok
Here is my setup:
Windows 10 PRO - build 19041.153 - insider program - slow ring
Ubuntu 18.04LTS subsystem in WSL2 mode
Docker for desktop 2.2.0.4 - enabled WSL2 integration with my Ubuntu subsystem
I am currently forced to use Windows for development, so I became a
Microsoft insider member and installed ubuntu with WSL2 mode. Docker desktop supports integration for WSL2, so I tried it...
For a week it worked flawlessly. Today after a PC restart, I can't get docker running again. Ubuntu can see the injected binaries from Docker desktop, but it can't connect to windows hosted docker daemon anymore.
When I call in the WSL terminal docker info it returns
$ docker info
Client:
Debug Mode: false
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
or with docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
What I've tried already:
expose daemon without TLS with envs like DOCKER_HOST=localhost:2375, DOCKER_HOST=tcp://localhost:2375, DOCKER_HOST=127.0.0.1:2375, DOCKER_HOST=tcp://127.0.0.1:2375 => same result
uninstall Docker desktop and install previous version
turn off windows firewall
I really, really need this to work. Thanks for any ideas. Weirdest thing is it worked yesterday and I didn't make any changes in system from then...
I know this may be outdated for the present question, but this should save us precious time, especially when Windows 20H1=2004 is going to Production this month (May 2020).
Operating System Version: Windows 10 Education (Same as Enterprise and a superset of Pro).
Version: 2004
Build (Version OS): 19041.264
Others: Windows Feature Experience Pack 120.2202.130.0.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shell: WSL Terminal
First, I have installed WSL v1 previously, then executed the procedure to upgrade to WSLv2, and this error shows up: "ERROR: Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?".
Second, to fix that error, I followed instructions stated here: Link, and it worked.
Third, after some tests I think the missing change in the upgrade, was removing the DOCKER_HOST variable from shell's start script.
SUMMARY: In my case, the procedure for a permanent fix should be the following STEPs:
1. Test if it's your case unsetting DOCKER_HOST variable (See image below).
2. If the error disappears with previous step, then time to fix changes by removing the setting of the DOCKER_HOST variable in the shell's start script (In my case was *$HOME/.bashrc*).
Commented this out:
#export DOCKER_HOST=tcp://localhost:2375
#export DOCKER_BUILDKIT=1
NOTE: Also include DOCKER_BUILDKIT.
3. Close and open the Terminal.
Test in Step 1:
Good luck!!
If it helps anyone else that is having this issue, for me it turned out that my subsystem was suddenly (and "on its own") ticked off in docker's RESOURCES > WSL INTEGRATION settings.
On the Docker Desktop app I had to manually enable my distro integration under
Settings > Resources > WSL Integration
I had installed Docker for Windows, as recommended, to use it with WSL 2 and that does indeed start the docker daemon for you. But I don't need all the fancy features it offers so removed it and was pleased to see about 4GB freed and no extra icon in the system tray.
Now if I need to run docker commands I just begin with:
sudo dockerd &
This way I can have it running on the background on the same shell. Note that in this example I have setup sudo without password. If a password is required, I can do sudo dockerd and open another terminal tab.
Although this works as a quick temporary solution I've seen it cause network issues so I would not recommend it, and prefer using a light VM instead.
I've tried soooo many things, and the stuff that worked for me, and no one ever mentioned to try:
(from Windows Powershell)
wsl --set-default <my-distro>
then and there, I could connect to docker without changing the DOCKER_HOST var.
1.open windows docker desktop --> Setting -->General --> Disable Expose daemon on tcp://localhost:2375 without TLS
2.and then Go to Settings --> Resources --> WSL integration --> uncheck Enable integration with my default WSL distro and turn off integration with distro
3.click apply and restart
4.then go to ubuntu
try docker ps
docker ps
if it does not work, continue to run the following command
unset DOCKER_HOST to disable DOCKER_HOST
Today I just tried it successfully
good luck to you
I have found my issue was due to mis-reading instructions., fixed on my windows version 1909 and WSL 2 with the following commands on CMD:
wsl.exe -l -v
wsl.exe --set-version ${distro-name} ${wsl version}
example:
C:\Users\xxxxx>wsl.exe -l -v
NAME STATE VERSION
* Ubuntu-18.04 Running 1
docker-desktop-data Running 2
docker-desktop Running 2
C:\Users\xxxxx>wsl.exe --set-version Ubuntu-18.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
That's it
ISSUE: Cannot connect to the Docker daemon at tcp://127.0.0.1:2375
Powershell
wsl -l -v # ALL DISPLAY "2"
Linux
unset DOCKER_HOST
/etc/init.d/docker restart
Restart Docker
windows docker restart
windows firewall off
Linux docker processes
docker ps
I had the same problem, the solution for me was to set my Ubuntu as the default wsl distribution: wsl --set-default Ubuntu
For whatever it's worth (this is an old thread). Maybe someone else is still desperately trying to solve this puzzle.
I have just stumbled over the solution in my case.
I am running the following
docker desktop version 3.3.3
wsl 2
Fedora 33
Over and over again I ran into this issue "Cannot connect to the Docker daemon at unix:///var/run/docker.sock". Reinstalled, restarted, blablabla.
My ultimate error were access rights on /var/run/docker.sock, and I am running wsl under my personal user
srw-rw---- 1 root docker 0 May 7 10:29 /var/run/docker.sock
So if I run as root (sudo docker info) or I put myself into group "docker" (sudo usermod -aG docker $USER) I'm all well. Please look here https://docs.docker.com/engine/install/linux-postinstall/
There is another very basic catch:
Ensure virtualization is enabled in the BIOS.
Please enable the Virtual Machine Platform Windows feature from the selection of additional Windows Features.
Now my motherboard is being very old, the BIOS does not support
Enabling Virtualization.
Hence no solution will work for me.
WSL Version 1 or 2 will come from Windows Update automatically.
After hours, my docker worked using following method.
Go to docker desktop --> Setting -->General --> Disable Expose daemon on tcp://localhost:2375 without TLS
Go to Settings --> Resources --> WSL integration --> uncheck Enable integration with my default WSL distro and turn off integration with distro
Restart Docker desktop
Now in WSL,
unset DOCKER_HOST
Now try,
docker ps
The accepted answer is mostly correct. However, I wanted to specify that when using WSL2 + Docker Desktop:
You must unset DOCKER_HOST which was previously needed in WSL1
Mine was defined in ~/.bashrc in both Windows and WSL.
Delete in both. Also delete in Windows env variables via Control Panel.
Check with env | grep -i docker to make sure it's gone.
You must also set the correct settings in Docker Desktop
Uncheck Export daemon on tcp://localhost:2375 without TLS
Check Use the WSL2 based engine
Resources -> WSL Integration -> Check Enable integration with my default WSL distro
Now, you can do a simple docker info to check if you're running the same server version in WSL and in Windows (Powershell).
you can consider upgrading your version to 19582.1000 , it's work for me.
See this issue.
Using the newest version of Docker as of August 25, 2017, I know that Docker no longer requires a VirtualBox setup along with boot2docker to work. However, in trying to connect to it and use docker-compose, I am unable to connect to docker. My compose file works as when I install all necessary prerequisites using homebrew (and therefore use docker-machine), everything is fine. The error message is as follows:
Couldn't connect to Docker daemon. You might need to start Docker for Mac.
I have since done the following to no avail:
remove ~/.docker folder
restart docker through the app
restart the docker app itself
open a new terminal session
It turns out I had some old docker environment variables in my ~/.bash_profile that docker-compose was reading and trying to connect to docker-machine, as a result. After commenting out the following from my ~/.bash_profile:
export DOCKER_CERT_PATH=/Users/williamrwatson/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST=tcp://192.168.59.103:2376
I was good to go:
Creating network "docker_default" with the default driver
Creating docker_redis_1 ...
Creating docker_redis_1 ... done