two weeks ago I had to stop a Thingsboard/Postgres container, due to maintenance of the Linux server. Now I try to start it again, but get the error:
docker inspect returns:
…
0.0.0.0:80->9090/tcp
…
docker container start returns:
Error response from daemon: driver failed programming external connectivity on endpoint prod_ec-thingsboard-prod_1 (c54cbc3ba0139d0e1f937d6e4a99540e0da2a078313cce7fda6a2f42fccd790a): Bind for 0.0.0.0:8080 failed: port is already allocated
Do I understand correctly, that the host at port 0.0.0.0:8080 was in the meantime allocated for a different process? I tried netstat -nlp , and indeed the Local Address 0.0.0.0:8080 port has a Foreign Address 0.0.0.0:* and state “listen”. But how can I identify by which process it is allocated?
Congrats, you found an ancient server with Linux Kernel from 14-Dec-2020 and Docker 20.10.5 from 2021-03-02 Maybe some bugs have been fixed since then. Not to mention security improvements.
docker ps shows you which containers use which ports.
netstat -tulpn shows you which ports are used on host.
You are using the docker.io package which is maintained by the Ubuntu developers, not Docker Inc. I understand that you were not the one who installed it, but the package itself another reason why it is harder to help you with this issu today.
You are also using Docker Compose v1, which was discontinued long time ago.
You either typed the output incorrectly or you forgot to share some details as you showed tht the port is forwarded from the host from port 80, but you get an error message about port 8080.
I also don’T see that you shared the output of
Is it because you got nothing or you forgot to run that? Whe you have port issues after a restart, that can also be because you have another Docker daemon and a container is running on that port. In this case I think you would have had an error message about the docker socket instead of ports, but the output could still be important.
Or if there is no other docker daemon, it could be a systemd service that was just stopped before but not disabled, so it started a porcess on a port before Docker started..
docker info and docker version outputs would also help
@rimelek: since a Debian kernel matching the one from Debian 11 is used, most likely a derivate of Debian Bullseye is used, which to my knowledge does not use snap.
Note: the official docker repository for bullseye is still maintained. Installation instructions to install vanilla docker: Debian | Docker Docs
If you want to stick to your current, non-vanilla docker, installation, there is not much we can do for you. The support channel for the docker package you are using is the Debian community. You would need to ask them for assistance.
It indicates a process on the host already binds this port on at least one of the ips.
The output of sudo netstat -tlpn | grep ":8080 " should show which process binds the port.
If the process is docker-proxy, I am curious if it works after rebooting the vm.
There used to be a kernel bug that sometimes had race conditions when releasing/binding ports, though your kernel version shouldn’t be affected anymore (see: When the blue whale sinks)
Snap could be installed on Debian 9 and above, but probably not installed by default, so snap Docker is not likely to be installed accidentally. Thanks for bringing it to my attention.
Indeed we use Debian bullseye (version 11). I guess that is why snap list docker doesn’t work here
It was my mistake about the port, docker inspect returns: “9090/tcp”: {“HostIp”: “0.0.0.0”,“HostPort”: “8080”}
It appears as is an older container, who should be stopped, started running again. This blocked my container somehow. Now the Thingsboard is active again.
I will research whether a vanilla docker installation is possible on our server.