Running Docker for Windows, Error when exposing Ports - docker

I am aware there are a lot of questions about running Docker on windows, however this question is about running the brand new Docker for Windows, on Windows.
In my case I am using Windows 10 Pro 64 bit. According to the site this version should be supported.
I have been following a tutorial I found here:
https://prakhar.me/docker-curriculum/
I also tried following the official guide of course: https://docs.docker.com/docker-for-windows/
In both tutorials I get the same error message when trying to assign a port using either the -P parameter or when trying to specify a port -p 8080:5000:
In the official guide I run docker run -d -p 80:80 --name webserver nginx and get:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint webserver (f9946544e4c6ad2dd9cb8cbccd251e4d48254e86562bd8e6da75c3bd42c7e45a): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:80:tcp:172.17.0.2:80: input/output error.
Following the unofficial guide i run docker run -p 8888:5000 prakhar1989/catnip and get basically the same error:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint focused_swartz (48a0c005779c6e89bf525ead2ecff44a7f092495cd22ef7d19973002963cb232): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:8888:tcp:172.17.0.2:5000: input/output error.
If I don't try to assign a port the container will run, but then I don't know how to access it.
The docker version I am running:
Docker version 1.12.3, build 6b644ec`
docker-compose version 1.8.1, build 004ddae`
docker-machine.exe version 0.8.2, build e18a919`
Any help would be very appreciated. Thank you.

Here's a new twist.
The last Windows 10 update (Fall Creators Update, 2017) has a new "feature". It automatically starts any applications that were running when you last shutdown.
This reconstitutes Docker for Windows in a bad state. That made it appear those ports were in use by something else - it was the ghost of itself. This explained why those ports were still in use even though I stopped/started my containers and even reboot!
The solution in this case is to simply restart Docker daemon.
To prevent this after the next shutdown, don't use the shutdown button. Type this instead:
shutdown /s /t 0
This bypasses the new feature.
See the answer from Jason[MS] in this thread:
https://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_perf-insiderplat_pc/programs-autostart-after-boot-in-windows-10-fall/09dd8d3e-7b36-45d1-9181-6587dd5d53ab
Here's one guy's workaround (from the end of this thread - haven't tried it myself):
http://www.icttoolbox.nl/info/stop-windows-10-creator-fall-reopening-programs-reboot/

Restarting the Docker daemon fixes this problem temporarily, but to get rid of it ultimately I had to disable Windows 10 fast startup, which is the feature #biscuit314 described.
To disable Windows 10 fast startup, get to the Control Panel > Power Options > Choose what the power buttons do > Change settings that are currently unavailable > Uncheck Turn on fast startup (recommended) and hit Save changes

This is caused by a port numbering conflict: github issue here https://github.com/docker/compose/issues/3277
Essentially the port is in use! The reason resetting worked is because it wiped other mappings off.

1) Stop all the running containers docker stop $(docker ps -a -q) then
2) Stop the Docker on your machine & restart it.
Then run the required command. This will solve the issue.

If its in windows OS, Please do restart the Docker
This has fixed the issue for me

For Linux - Debian Users,
Use docker stop $(docker ps -a -q) only when you know whether you want to stop all the containers or not.... If yes then please run docker rm $(docker ps -a -q) to remove containers ....
Then stop the docker daemon - systemctl stop docker
Then start docker daemon - systemctl start docker
Also verify whether docker daemon is up or not - service docker status
After following all above mention steps you should be fine.....

I got the same issue before on window 10.
Restart docker, it works

Try stopping docker and initiating it again on administrator mode. After it starts open power shell on administrator mode as well.
Because the error says "mkdir" maybe this will solve your problem. Im not sure but it worked for me.
In the case of using -P a port conflict does not seen to be the reason for the error once -P will chose ports randomly. The error it self wasn't quite friendly to me but because I saw the mkdir word on it I imagined it might be a permission error, thats why I restarted docker on administrator mode and started power shell on administrator mode.

I tried all the suggestions on this issue: killing all the containers, restarting Docker Desktop, disabling "Fast Startup," restarting my computer, making sure "Experimental Features" were disabled. None of that stuff worked.
I did eventually get it running. Here are some things you may want to try (because I'm not sure what actually fixed it).
Find "Docker Desktop" and right-click to "Run as Administrator..."
Pay attention to the port that it's complaining about. Some people say this could just be Docker's unfriendly way of saying "that port is in use." In my case, the port was 80. I went into the Services on Windows Pro and disabled the "World Wide Web Publishing Service" just to be safe.

If you are here because you have this issue in Visual Studio 2019:
According to this post, the VS team is preparing a fix for this issue in 16.5 version, meanwhile, you can add the property "publishAllPorts": true in your launchSettings.json, for example:
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:44374", #<== Set a fixed port
"environmentVariables": {
"ASPNETCORE_URLS": "https://+:44374;https://+:5000",
"ASPNETCORE_HTTPS_PORT": "44374"
},
"publishAllPorts": true, #<== This is equivalent to the -P flag in 'docker run'
"useSSL": true
}
Notice that the property "httpPort": XYZT is not defined. Having it defined will make the workaround not work.
It worked for me with this setup:
Windows 10 1709 Build 16299.1747 with Fast Start OFF
Docker Desktop 2.2.05 (43884)
Docker Engine 19.03.8
Visual Studio 2019 Enterprise 16.5.4.
Microsoft.VisualStudio.Azure.Containers.Tools.Targets 1.10.8
I realized that the command VS was creating, contained the -p parameter twice, one with the port I specified and another with port 80, like this: -p 3010:80 -p 3010:3010.
After adding publishAllPorts it now creates the container and I can remotely debug it.

This is what worked for me after trying every thing. Seems we need to kill the running process.
Exit docker, right-click the icon Quit Docker Desktop
Open the windows task manager, find and kill the process com.docker.backend.exe
restart docker, double-click the icon to open the Docker Desktop

Related

error during connect: The system cannot find the file specified..,the docker client must be run elevated to connect [duplicate]

System info:
Windows 10 pro 64 bit
C:\WINDOWS\system32>docker --version
Docker version 18.06.1-ce, build e68fc7a
C:\WINDOWS\system32>docker info
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.38/info: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
C:\WINDOWS\system32>docker pull hello-world
Using default tag: latest
Warning: failed to get default registry endpoint from daemon (error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.38/info: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.). Using system default: https://index.docker.io/v1/
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.38/images/create?fromImage=hello-world&tag=latest: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
You can powerShell as admin.
Run this code:
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon
Running Powershell with elevated access solved my issue.
Usually this error means the Docker daemon that is docker services is not up and running.
Make sure docker is running by issuing below command in power shell in elevated mode.
docker run hello-world
A response as hello from docker will be printed on console.
Else start the docker by double clicking the docker app from start menu.
Below is the snapshot of graphically up and running docker daemon.
On Windows, go to the folder %homepath%\.docker, open daemon.json and if debug is set to true then set it to false.
I had the same error as in the question and after I changed the above it worked again for me. After I got the error, I had been looking at the various docker settings and decided to set debug to false because I don't need any daemon debug info for what I'm doing. I don't know why it was set to true originally.
In my case, although I had the docker service running as admin and the service was shown as running, it was not.
Open the docker desktop app, click on the 'troubleshoot' icon. Check if the service is effectively running (bottom left). If it's not, try to 'clean/purge data', and then restart the service. It worked for me!
Verify it by running docker run hello-world
Fow Windows:
Launch command: "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon
This error is because of organisation network certificates which are installed in local machine. Beacuse some companies restricted network by installing certificates.
docker daemon service is not running on my machine and when I start the service, this error us resolved.
I had faced the same error, the following worked for me:
In the windows taskbar, the docker icon was red in color saying Out of Memory...
In the Docker Desktop App, goto
Settings -> Resources -> Disk Image Size -> decrease the space allocated -> Apply & Restart
This did happen to me while i was using docker today for the first time. I fixed by opening up the docker app in the PC and signing and selecting the necessary subscription plan.
Open docker with docker <homepath>. Simply upgrade docker and then run this command
docker-compose up -d
you will be able to solve the specified path error.
docker.errors.DockerException: Error while fetching server API version: (2, 'CreateFile', 'The system cannot find the file specified.')
[14620] Failed to execute script docker-compose
Doing the above solved the error.
Yo,
open docker app > settings > Docker engine > "debug": true,
debug was false initially, after changing it to "true" it worked.
Thanks.

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.

error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.38/info

System info:
Windows 10 pro 64 bit
C:\WINDOWS\system32>docker --version
Docker version 18.06.1-ce, build e68fc7a
C:\WINDOWS\system32>docker info
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.38/info: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
C:\WINDOWS\system32>docker pull hello-world
Using default tag: latest
Warning: failed to get default registry endpoint from daemon (error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.38/info: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.). Using system default: https://index.docker.io/v1/
error during connect: Post http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.38/images/create?fromImage=hello-world&tag=latest: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
You can powerShell as admin.
Run this code:
cd "C:\Program Files\Docker\Docker"
./DockerCli.exe -SwitchDaemon
Running Powershell with elevated access solved my issue.
Usually this error means the Docker daemon that is docker services is not up and running.
Make sure docker is running by issuing below command in power shell in elevated mode.
docker run hello-world
A response as hello from docker will be printed on console.
Else start the docker by double clicking the docker app from start menu.
Below is the snapshot of graphically up and running docker daemon.
On Windows, go to the folder %homepath%\.docker, open daemon.json and if debug is set to true then set it to false.
I had the same error as in the question and after I changed the above it worked again for me. After I got the error, I had been looking at the various docker settings and decided to set debug to false because I don't need any daemon debug info for what I'm doing. I don't know why it was set to true originally.
In my case, although I had the docker service running as admin and the service was shown as running, it was not.
Open the docker desktop app, click on the 'troubleshoot' icon. Check if the service is effectively running (bottom left). If it's not, try to 'clean/purge data', and then restart the service. It worked for me!
Verify it by running docker run hello-world
Fow Windows:
Launch command: "C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon
This error is because of organisation network certificates which are installed in local machine. Beacuse some companies restricted network by installing certificates.
docker daemon service is not running on my machine and when I start the service, this error us resolved.
I had faced the same error, the following worked for me:
In the windows taskbar, the docker icon was red in color saying Out of Memory...
In the Docker Desktop App, goto
Settings -> Resources -> Disk Image Size -> decrease the space allocated -> Apply & Restart
This did happen to me while i was using docker today for the first time. I fixed by opening up the docker app in the PC and signing and selecting the necessary subscription plan.
Open docker with docker <homepath>. Simply upgrade docker and then run this command
docker-compose up -d
you will be able to solve the specified path error.
docker.errors.DockerException: Error while fetching server API version: (2, 'CreateFile', 'The system cannot find the file specified.')
[14620] Failed to execute script docker-compose
Doing the above solved the error.
Yo,
open docker app > settings > Docker engine > "debug": true,
debug was false initially, after changing it to "true" it worked.
Thanks.

Docker now giving an error after updating

After using Docker for almost two months, today I got the following error:
C:\Users\dell>docker --version
Docker version 17.06.0-ce, build 02c1d87
C:\Users\dell>docker ps -a
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.30/containers/json?all=1:
open //./pipe/docker_engine: The system cannot find the file
specified. In the default daemon configuration on Windows, the docker
client must be run elevated to connect. This error may also indicate
that the docker daemon is not running.
Yes, the daemon is running, or at least it is shown as running under Services. I use it only with a local container and do not do anything remote.
Any suggestions on how this can be solved?
Well, I have had the same issue today and the only way for me to fix it was by reinstalling Docker (uninstall and install latest stable version)...
Now docker info runs OK and my solution builds again.
I hope it helps,
Juan
Note: it shouldn't have happened at all, I've lost at least one hour trying to figure out what and why it crashed...
Is Hyper-V running? You will get this error if Hyper-V closes down. Docker for Windows will still be "running", but the daemon will not work.

Docker run does not deploy

So we followed the Docker get started tutorial
(https://docs.docker.com/get-started/part2/). The build works, the command
docker run -p 4000:80 friendlyhello
works but when we go to http://localhost:4000, nothing is reached. We just followed the tutorial step by step but don't see anything.
Yes we also went to localhost:4001.
Is this perhaps something that has to do witht the message "system pool is not available on windows"?
Here's a screenshot of our docker output
Firstly talking about the issue that you've pointed out yourself, this is identified as an issue that can't be fixed for Windows.
Please try downgrading to version 1.12.x so that these warnings do not pop-up anymore. This solution is found working for most of us.
level-info msg="Unable to use system certificate pool: crypto/x509: system root pool is not available on Windows"
Coming to the main issue that you're facing, which is as follows:
Error response from daemon: driver failed programming external connectivity on endpoint objective_joliot
This says that the port 4000 is already in use on Docker VM or possibly on your system. You can either stop whatever is running on that port or change the port used in your Docker command.
To change to the external port 8080, use:
docker run -d -p 8080:80 --name objective_joliot nginx
Hope this helps!!!

Resources