简体   繁体   中英

Docker - "Ports are not available" problem on Mac

I've done a mini project with Java Spring and I'm trying to Dockerize it. Everything is going fine until I try to run the docker. When I'm running the docker I get a "Ports are not available" error.

文件

终端

I have been trying to set the EXPOSE on the Dockerfile to many other ports (8085, 9000, 9090...) and changing the docker run command accordingly but nothing worked. Another thing to mention is that when I'm trying to access "http://localhost:8080/" to see if it is actually taken, there is nothing there.

How do I fix it?

Update: I tried running the getting-started docker and it gave me the same error message so the problem is with my docker. Does anyone got the same problem and was able to fix it?

So I finally managed to solve the problem. There were a few problems that I had:

In the Dockerfile:

  1. My java version is 11 so I had to change the line in the Dockerfile to "FROM openjdk:11".

  2. I needed to add ".jar" to the last parameter in the ADD line. (changed it to ADD target/digital-wallet-docker.jar digital-wallet-docker.jar)

In my firewall: I needed to modify my privacy settings. I enabled the Location Services for Docker and it solved the "Ports are not available" error that I had.

Hope it'll help :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM