-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: bind: address already in use in make run #430
Comments
what is your environment and recreate steps? |
The environment is When the error appears, we check the ports and they are free. |
@idiazcir, try running I never have this issue, but still on |
We normally do a It was also occurring in version 24 of Docker (we just upgraded to version 25 to see if it was solved). As said, we posted it in case more people had the same issue. We assumed that was the case as it happens to everyone on our team every so often. |
Clearly something on your system, outside of EdgeX, has port Please verify you have the same issue in non-secure mode. run Then, try running Core Command from command-line to eliminate Docker and see if issue still exists.
Verify if service exists due to port bind issue or stay running. |
Thanks a lot for the suggestion! In case we ever encounter the problem again, we will try this. As I said, we changed the port bindings to avoid this error from appearing. Reverting the bindings to try to cause the error is not as easy either, as it only happens occasionally. We didn't find a way to force it. |
Hello @idiazcir I have encountered this error a few times & I have managed to fix it with the following commands : You can try these out & check if it fixes the error.
Now you can continue using make run to bring up the application. Thanks. |
thanks for the solution, closing this issue |
🐞 Bug Report
Affected Services
The issue is located in: The
make run
with the ports binding.Is this a regression?
NoDescription and Minimal Reproduction
Not exactly a bug, but rather a problem that we are encountering usually when deploying (
make run
) EdgeX. It is an error from Docker. It has been tracked in this issue here.However, it can be avoided by defining the ports for the containers differently. Hence, we consider it could be changed in the code to prevent it from happening until an official fix is done.
The issue is caused by a collision of the ports used for the dockers. In some occasions when we run EdgeX via a
make run
, the command will fail due to an error on the ports used, being already in use. When that happens, the following error appears.As said, we belive the error can be traced down to how Docker is using the ports defined on the docker compose file. In there, we have for every module, something similar to this:
This is equivalent to (as in the
docker-compose-base.yml
)In this case, the module that failed was the
edgex-core-command
, but it happens for the rest as well.The same Docker problem can be caused if you have a process running on the same port. In our case, this is not the case, there are no processes running in the port when it collides. Therefore, we belive it is related to how internally Docker launches the containers and binds the ports. We have found three ways of solving this.
Solution 1: Only choose the internal port. Let Docker choose the external one.
This prevents the collision, however, it causes the external port to be randomly chosen by Docker, thus making it hard the be used for applications with an exposed interface. Based on this issue answer.
Solution 2: Choose both ports, but different ones.
In the same way, setting the two ports but with different values seems to work fine (avoids collisions). We believe this is not a large change. As of our understanding, as long as the internal ports remain the same, changing the external ones should not be too complex. Based on this (we used a better resource, but couldn't find the link).
Solution 3: Remove the ports if not needed.
This solution is the best one if the service doesn't have an exposed interface. Internally everything will keep running fine as the containers are in the same network. The only thing is that they won't be exposed to the exterior. As of our understanding, aside from for testing purposes, this can be done for all modules except consul, vault, and the ui. The rest as they don't expose an extrenal interface, the ports can be removed.
This has been tested for our own services, and works fine. We have removed all the ports for services that don't expose an interface (solution 3) and put two different ports for those that do (solution 2). We, however, still have collisions in the core modules of EdgeX as this remains the same there.
We do not know if this problem is something that happens on some occasions to you or other EdgeX users. In our case, it happens sometimes, and it is quite frustrating as we need to bring down and re-run the containers until it works (and seamlessly there are no bind collisions). As already mentioned, we have managed to reduce the appearance of this error by implementing these changes in our own services. The
make run
will still occasionaly fail on the core modules binds.🔥 Exception or Error
🌍 Your Environment
Deployment Environment: Ubuntu 20.04
EdgeX Version: 3.0
Anything else relevant?
While we are currently using version v3.0, version v3.1 has ports defined in the same way, so the error will persist. The original issue being tracked in Docker has not been added to v25.0 as the author suggested may be.
As said, this is not the fault of EdgeX, and we know if this is something extended, or if it only happens to us. In any case, we hope this is useful.
The text was updated successfully, but these errors were encountered: