Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker port bind fails. Why a "permission denied"?

I'm trying to start a jenkinsci/blueocean container under Windows 10 Pro (latest). I'm running a script:

docker run ^
  --rm ^
  -u root ^
  -d ^
  -p 8080:8080 ^
  -p 50000:50000 ^
  -v D:/docker/jenkins/volumes/jenkins-data:/var/jenkins_home ^
  -v D:/docker/jenkins/volumes/docker.sock:/var/run/docker.sock ^
  -v D:/docker/jenkins/volumes/home:/home ^
  jenkinsci/blueocean

This fails with the following message:

docker: Error response from daemon: 
  driver failed programming external connectivity on endpoint elastic_kare: 
  Error starting userland proxy: 
    Bind for 0.0.0.0:50000: unexpected error Permission denied

If I leave out the binding of port 50000 it works fine, but I need the 50000 port to communicate with the slaves on the host.

Binding 50000 to another port doesn't help. The port is not in use, according to netstat -an. Trying to run the script as Administrator didn't help.

What could be the issue here?

update: I restarted my laptop and updated Docker Desktop to the latest version as well.

update2: after restarting laptop I restarten Docker (several times) as well. To no avail.

update3: shutting down the Windows Firewall did not solve the problem.

like image 200
Bronco Oostermeyer Avatar asked Jan 16 '19 12:01

Bronco Oostermeyer


People also ask

How do I fix Docker permission denied?

Fix 1: Run all the docker commands with sudo If you have sudo access on your system, you may run each docker command with sudo and you won't see this 'Got permission denied while trying to connect to the Docker daemon socket' anymore.

What is port binding in Docker?

Docker containers can connect to the outside world without further configuration, but the outside world cannot connect to Docker containers by default.

What port should I use for Docker?

Map TCP port 80 in the container to port 8080 on the Docker host for connections to host IP 192.168.1.100. Map UDP port 80 in the container to port 8080 on the Docker host. Map TCP port 80 in the container to TCP port 8080 on the Docker host, and map UDP port 80 in the container to UDP port 8080 on the Docker host.


1 Answers

If you're running Docker on Windows then it will be using Hyper-V - I've found that Hyper-V reserves a bunch of ports - you can find out by running this:

netsh interface ipv4 show excludedportrange protocol=tcp

On my machine I could see it had reserved port 50000. To free this port up I disabled Hyper-V:

dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

After the reboots, I reserved port 50000:

netsh int ipv4 add excludedportrange protocol=tcp startport=50000 numberofports=1

Then enabled Hyper-V again:

dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

When it came back up I could run Jenkins in Docker on Windows:

docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts
like image 175
Mattl Avatar answered Oct 18 '22 20:10

Mattl