Hello,
I am using docker and docker-compose now quite for some time. Recently I had a strange behavior and I cannot understand what it is all about.
I had a minimalistic docker-compose.yml
file with a single container configured. This container was built from a subdirectory and running, sharing some ports and some mounts. All right so far.
I have then changed something within the build environment and thus triggered the build. A few seconds later, the new image was finished. Normally, I am used to just do a docker-compose up -d
in order to recreate the container with the shiny new image.
In my case the following error
Recreating nginx-live-stream_nginx_1 ... error
ERROR: for nginx-live-stream_nginx_1 Cannot start service nginx: driver failed programming external connectivity on endpoint nginx-live-stream_nginx_1 (1218f72816a19b9ab1ee4656f9845d6f2d60106c1176238515066cebf19cbde7): Bind for 127.0.0.1:1935 failed: port is already allocated
ERROR: for nginx Cannot start service nginx: driver failed programming external connectivity on endpoint nginx-live-stream_nginx_1 (1218f72816a19b9ab1ee4656f9845d6f2d60106c1176238515066cebf19cbde7): Bind for 127.0.0.1:1935 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
The named port 1935
is in fact intended to be used by the container. When looking at the list of the containers, I am stunned:
# docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------------------------------------------------------------------------------------
afb1a1c2e6f3_nginx-live-stream_nginx_1 nginx -g daemon off; Up 127.0.0.1:1935->1935/tcp, 0.0.0.0:445->443/tcp, 127.0.0.1:81->80/tcp
nginx-live-stream_nginx_1 nginx -g daemon off; Exit 128
Looking at the corresponding output of docker ps
reveals that the container afb1a1c2e6f3_nginx-live-stream_nginx_1
seems to be a clone of the original container. I suspect the original container had the id afb1a1c2e6f3
but I no longer can check this.
I tried to get rid of the container using docker stop
, docker rm
and docker kill
. Nothing happens here. The container just sits there, immutable, and takes up the port I need. My last resort was to restart the complete docker service using systemctl restart docker.service
. This finally allowed me to remove the container.
Can anyone explain to me what is going on here?
# docker --version
Docker version 19.03.15, build 99e3ed8919
# docker-compose --version
docker-compose version 1.21.0, build unknown