I'm using the erikvl87/languagetool Docker image on my Mac, running the following command to start the container:
docker run -d
--name excentric_jazz
--restart=always
-p 127.0.0.1:55001:8010
erikvl87/languagetool
This should bind the container's internal port 8010 to 127.0.0.1:55001 on my host machine. However, for some reason, the container sometimes switches to using port 55000 without me changing anything. I haven't set up port 55000 anywhere else, and I only have this one container running, without any dynamic ports involved. What could be causing Docker to ignore my fixed port mapping after a restart, and how can I prevent it from switching to a different port like 55000?
2 Answers
There are a few possibilities here. One option might be a bug in Docker Desktop for Mac, although that seems a bit unlikely. Another thought is that there could be an issue with how Docker handles high-numbered ports, but that’s a stretch since 65535 is the max. The most probable reason could be that you had started another container in the past using the same settings. If that container is still running, especially if it's set to restart, it might cause conflicts. You should check all running containers with `docker ps -a` and consider shutting down any duplicates or starting fresh with a completely new container.
I suggest steering clear of using ports in the ephemeral range for binding. This could lead to potential conflicts with other applications that might be trying to connect.
Related Questions
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically
[Centos] Delete All Files And Folders That Contain a String