138

I am trying to use $ docker-compose up -d for a project and am getting this error message:

ERROR: for api Cannot start service api: driver failed programming external connectivity on endpoint dataexploration_api_1 (8781c95937a0a4b0b8da233376f71d2fc135f46aad011401c019eb3d14a0b117): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:9000:tcp:172.19.0.2:80: input/output error Encountered errors while bringing up the project.

I am wondering if it is maybe the port? I had been trying port 8080 previously. The project was originally set up on a mac and I have cloned the repository from gitHub.

1
  • Please add a link to the github ticket so that we all can go over there and upvote it. Jan 1, 2020 at 12:43

11 Answers 11

274

I got the same error message on my Windows 10 Pro / Docker v17.06.1-ce-win24 / Docker-Compose v1.14.0 using Windows Powershell x86 in admin mode.

The solution was to simply restart Docker.

4
  • I user docker Version 18.03.0-ce-win59 (16762) on Windows 10 Professional. Docker Image is jenkins/jenkins:2.107.2. After pull, I use this command to install docker run -p 8080:8080 --name myJenkins -p 50000:50000 jenkins/jenkins:2.107.2. After done setting jenkins, I use docker stop myJenkins in other command window and shutdown my host Windows 10. When I start windows 10 which starts docker automatically, I use command docker start myJenkins and get the familiar message. However, restarting docker solve to problem :)
    – Charles Wu
    Apr 20, 2018 at 1:21
  • 1
    Does anyone know why this happens? Restarting docker seems hacky, is there a way to solve this properly? Jan 25, 2019 at 11:33
  • Same fix worked for me in Mar 2019. Using Docker Desktop Version 2.0.0.3 (31259) Channel: stable Build: 8858db3 Client: Docker Engine - Community Version: 18.09.2 API version: 1.39 Go version: go1.10.8 Git commit: 6247962 Built: Sun Feb 10 04:12:31 2019 OS/Arch: windows/amd64 Experimental: false Win 10 Version 10.0.18346.1 ( fast version of pre release)
    – JohnC
    Mar 1, 2019 at 8:00
  • had the same issue on a Mac and restarting the docker fixed it as well... jesus I should have checked your answer before reinstalling the whole docker environment locally.... :D cheers mate
    – pofqggg
    Mar 4, 2020 at 11:49
68

If happens once, restarting Docker will do the work. In my case, it was happening every time that I restarted my computer.

In this case, disable Fast Startup, or you probably will restart Docker every time that your computer starts. This solution was obtained from here

2
  • 7
    This should be accepted as an answer. Restart works but when you need to do it every time it becomes annoying
    – Vitalii
    Oct 24, 2018 at 17:32
  • I got this error when switching users on Windows 10
    – Vasko
    Mar 21, 2019 at 9:22
59

Simply restaring Docker didn't fix the problem for me on Windows 10.

In my case, I resolved the problem with the exact steps below:

1) Close "Docker Desktop"

2) Run the commands below:

net stop com.docker.service
net start com.docker.service

3) Launch "Docker Desktop" again

Hope this will help someone else.

5
  • 3
    This works for me after trying just a docker restart! Also, do not forget to run this couple with admin privilege Aug 5, 2019 at 5:30
  • It worked, but I don't have admin privilege all the times :( Aug 28, 2019 at 5:27
  • 3
    Worked for me restarting the docker service, usually just a docker desktop restart was sufficient but not this time... docker on windows 10 is really painful (latencies, bugs, doc, ...)
    – FAjir
    Sep 2, 2019 at 15:32
  • This worked! Should be the real accepted answer. Thanks
    – JustRandom
    Oct 30, 2019 at 14:24
  • Worked for me, thnx! Jan 20, 2020 at 9:54
9

I got that error too, if you want to know the main reason why error happens, its because docker is already running a similar container, to resolve the problem( avoid restarting Docker), you must:

docker container ls

You got something similar to:

CONTAINER ID        IMAGE               COMMAND             CREATED
1fa4ab2cf395        friendlyhello       "python app.py"     28 seconds ago

This is a list of the running containers, take the CONTAINER ID (copy Ctrl+C)

Now you have to end the process (and let run another image) run this command.

docker container stop <CONTAINER_ID>

And thats all! Now you can create the container.

For more information, visit https://docs.docker.com/get-started/part2/

8

Normally this error happens when you are trying start a container but the ports that the container needs are occuppied, usually by the same Docker like a result of an latest bad process to stop.

For me the solution is:

  1. Open windows CMD like administrator, type netstat -oan to find the process (Docker is the that process) that is occuppying your port:

In my case my docker ports are 3306 6001 8000 9001.

  1. Now we need free that ports, so we go to kill this process by PID (colum PID), type

    TASKKILL /PID 9816 /F
    
  2. Restart docker.

  3. Be happy.

Regards.

7

I am aware there are already a lot answers, but none of them solved the problem for me.
Instead, I got rid of this error message by resetting docker to factory defaults:

enter image description here

3
  • Did you had any error report from Docker before doing that, because in my case I had something like an error pop up with the suggestion to reset to factory defaults. Nov 19, 2019 at 9:15
  • No, @TheodosiosAsvestopoulos, I did not get that pop up.
    – jasie
    Nov 19, 2019 at 10:50
  • Strange I had the same issue again today, docker restart did not help. I did not want to do reset to factory defaults again, because we pull really large images, so I just quit Docker Desktop and opened it again and it worked (seems to be a different action than just to restart it). Nov 20, 2019 at 11:28
2

In my case, the problem was that the docker container (Nginx) uses 80 port, and IIS uses the same. Setting up another port in IIS solve problem

0
1

In most case, the first case you should think about is there is an old service running and using that port. In my case, since I change the image name, then when using docker-compose to stop (then up), it won't stop old container (service), lead to the new container can not be started.

0

A bit of a late answer but I will leave it here it might help someone else On a Mac mojave after a lot of restarts of both mac and docker I had to sudo apachectl stop.

0
  • The simplest way to solve this is Restarting the docker. But in some cases it might not work even though you don't have any containers that are running in the port.You can check the running containers using docker ps command and can see all the containers that were not cleared but exited before using docker ps -a command.

Imagine there is a container which has the container id 8e35276e845e.You can use the command docker rm 8e35276e845e or docker rm 8e3 to end the container.Note that the first 3 strings are the id of that particular docker container id. Thus according to the above scenario 8e3 is the id of 8e35276e845e.

  • If restarting doesn't work you can try changing the ports of the services in the docker-compose.yml file and according to the apache port you have to change the port of the v-host(if there's any).This will resolve your problem.

Ex:

    build:
      context: ./apache
      dockerfile: Dockerfile
    working_dir: /var/www/
    volumes:
      - .:/var/www
    networks:
      - app-network
    ports:
      - 8082:80
    depends_on:
      - mysql_db

should be changed into

apache_server:
    build:
      context: ./apache
      dockerfile: Dockerfile
    working_dir: /var/www/
    volumes:
      - .:/var/www
    networks:
      - app-network
    ports:
      - 8083:80
    depends_on:
      - mysql_db

and the particular v-host also has to be changed,

Ex(according to the above scenario):

<VirtualHost *:80> 
    ProxyPreserveHost On
    ServerAlias phpadocker.lk
    ProxyPass / http://localhost:8083/
    ProxyPassReverse / http://localhost:8083/
</VirtualHost>

This will help you to solve the above problem.

0

For many windows users out there that have the same issue I would suggest to restart the computer also, because most of the times (for me at least) restarting just Docker doesn't work. So, I would suggest you follow the following steps:

  1. Restart your pc.
  2. Then Start up your PowerShell as admin and run this:

    Set-NetConnectionProfile -interfacealias "vEthernet (DockerNAT)" -NetworkCategory Private

  3. After that restart your Docker.

After completing these steps you will be able to run without problems. I hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.