Mastodon

This morning I had a Docker service fail to start. On inspection of the error, it turned out it was because the port was in use by another service. In this particular case, my Docker service was trying to use port 8029 so that’s what I’ve used in the examples below.

docker ps | grep 8029

This searches through your docker containers, and finds any that are running on port 8029. The output should look like this:

fec0c35f0b2d directus/directus:latest "docker-entrypoint.s…" 15 minutes ago Up 5 minutes 127.0.0.1:8029->8055/tcp directus-example

In the above example you can see that port 8029 was identified to be in use by the directus-example container. It turns out I did a test install of Directus on that port, and then forgot to delete it.

Stop the docker container:

docker stop fec0c35f0b2d

The container ID (fec0c35f0b2d) used above is from the first command which provided the container ID

Delete the docker container. In my case I no longer needed this Directus container, so I deleted the container too. If you need to keep your container, then just change its configuration to run on a different port that doesn’t clash.

docker rm fec0c35f0b2d

With this complete, I was able to start the Docker container that’s actually supposed to be running on port 8029 with no issues.

In my case I knew that the port would be used by Docker because I use that port range for Docker only. If you don’t know for sure that it’s Docker using the port, then you can use the following to check which service is using the port. Note that you will need sudo access to run this.

sudo netstat -tulpn | grep 8029

The output from this should tell you which service is using that port.

0
Would love your thoughts, please comment.x
()
x