Unsupported operating system with Docker on windows 10 with wsl2 - docker

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

Related

Why am I getting a "Cannot connect to the Docker daemon" error in WSL2?

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.

Sharing docker credentials between Window and WSL

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.

Couldn't Connect to Docker Daemon on Mac

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

Debugging Drupal on docker container using Atom

I am a little bit blocked here.
I am using Ubuntu 14 machine with Atom, where I am developing a Drupal-based system. The installation of the system is on a docker container that I run over a VM using Vagrant.
I can operate perfectly with Atom and run the local server to check changes. The problem is that using kint/dump is not enough, so I decided to install xdebug on docker container and php-debbuger on host machine. I also installed "The easiest Xdebug" on Firefox. But, they don't seem to get connected.
I followed this steps so far:
From docker
pecl install xdebug
inserted on php.ini
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
inserted on xdebug.ini
xdebug.remote_enable=1
xdebug.remote_autostart=0
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_log=/tmp/php5-xdebug.log
xdebug.remote_handler=dbpg
From host machine, on ../provision/docker-compose.yml, added the following:
environment:
XDEBUG_CONFIG: remote_host={{192.168.33.33}}
At firefox's add-on, set the IDE key as
xdebug.atom
From Atom, on php-debug - settings - Path Maps
/url;/home/myname/www/path/cms/
I am confused with the last one, but I tried different approaches and I am sure there are other settings to do. What am I missing?
My experience with Docker and XDebug is that you have to put your IP address in the Docker network.
Do a docker inspect [your_container_name] | grep -i gateway (when it's running) and use that IP for the remote host configuration in the xdebug.ini file.
If you want to debug further I recommend putting the remote host configuration directly in the xdebug.ini to make sure that the enviroment variable is being passed correctly.
After installing php-debug, put below setting into your Atom config (config.cson):
"*":
"php-debug":
PathMaps: [
"/path/to/app/in/docker;/path/to/app/in/local"
]
ServerPort: 9000
welcome:
showOnStartup: false
To get more information and instructions, you can read this post.

docker : When creating a machine, VT-X/AMD is enabled yet

I'm going through this tutorial
Dockerizing Flask With Compose and Machine - From Localhost to the Cloud
When trying to create a virtualbox with the command below
docker-machine create -d virtualbox dev;
I have the following error
Error creating machine : Error in driver during machine creation. This computer doesn't have VT-X/AMD enabled. Enabling it in the BIOS is mandatory
(Addendum: I'm running an ubuntu image on a virtual box. The physical host is a windows machine. The VT VT-X/AMD is enabled both , in the bios and in the virtualbox.)
Reading here and there, it seems to be a normal behavior because I'm trying to create a virtualbox within a virtualbox -> Click here for the explanation
What command should I use instead of docker-machine ?
Any insights are more than welcomed ...
Update: I've asked 3 additional questions to #VonC after his initial answer. Please find the questions below , in italic
1) How should I make the virtualbox and the docker config see that new "virtualbox"?
2) Will the ubuntu box, be able to do the docker-compose and build the container on that host?
3) If I'm pulling an image like debian, how can I use it as a machine and build an container on top of it?
If you do not want to change the BIOS settings, please run the below command.
I have the same problem because I have Hyper-V manager installed in my Windows 8 server. To avoid this issue I ran the below with the below option
--virtualbox-no-vtx-check
Example: docker-machine create default --virtualbox-no-vtx-check
I'm in a VM already , running ubuntu. Physical host is a windows machine
Then you don't need docker-machine.
You would create a small Linux image from windows with (again, type in a regular Windows CMD shell)
docker-machine create -d virtualbox dev
But on a full-fledged Ubuntu VM, you just need to install docker and run it directly.
If you need to use docker-machine, just copy (on Windows) v0.6.0-rc1/docker-machine_windows-amd64.exe as docker-machine.exe anywhere you want.
Also: set VBOX_MSI_INSTALL_PATH=C:\Program Files\Oracle\VirtualBox\ (if your VirtualBox is installed there)
You now can use docker-machine -d virtualbox dev.
2) Will the ubuntu box, be able to do the docker-compose and build the container on that host?
Yes, no issue there. The installation is straightforward.
3) If I'm pulling an image like debian, how can I use it as a machine and build an container on top of it?
You simply write a Dockerfile starting with FROM debian:jessie (see an example here), add some commands (RUN, COPY, ...): for instance:
FROM debian:stable
RUN apt-get update && apt-get install -y --force-yes apache2
EXPOSE 80 443
VOLUME ["/var/www", "/var/log/apache2", "/etc/apache2"]
ENTRYPOINT ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
Build it (docker build .)and run it (docker run).

Resources