Docker
I am trying to start databse by docker but it fails by saying that that port is already in use
"Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:5432 -> 0.0.0.0:0: listen tcp 0.0.0.0:5432: bind: address already in use"
But then i run
- lsof -i :5432
It shows nothing. No other docker image or container is running.
55 Replies
does whatever you're doing work when you use another port?
i am just starting to learn all of these stuff and was following a tutorial
and since i had this error was curious what was the reason
and what can cause it
so what command are you using to start the container?
docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d
can you pastebin the contents of your compose files?
Show your docker-compose.yml file
do what?
Ok so
You know that file
version: '3.4'
services:
catalogdb:
image: postgres
catalog.api:
image: catalog.api
build:
context: .
dockerfile: Services/Catalog/Catalog.API/Dockerfile
volumes:
postgres_catalog:
Docker-compose.yml
Yes
Ok do you have any other files? Maybe a Dockerfile?
this is override
this is dockerfile
Ok so try running
docker ps
Let us know the outputits empty
Ehat command are you running to start the containers?
docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d
And you arent running anything on your actual machine thats using port 5432?
no
i checked it via lsof -i :5432
and it outputed nothing
that's why i was confused
Hm
we can call if it is better for you
That is strange
Unfortunately im at work
sure
i am using mac if that changes anything
Oh wait
How are you running this?
Vm?
rider
Docker desktop?
rider has built in docker executor
Brb
no, now i am trying to run it thru terminal
by this command
docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d
Does this work?
docker run --rm -p 5432:80 nginx
alright, something on your machine is definitely already running on port 5432
yeah i guess it is jjust a waste of time. i've been debugging it for 2 days
anyways thanks for the time
netstat -tuln | grep 5432
Does that highlight anything?
damn
i hting you found it
that looks like it's a bit of a red herring
i will literally never forget that command
thanks a lot
❤️
wait, you've fixed it?
i think that's just a red herring. do you get any different output with lsof run as root? it could be another user has the port in use.
yeah i could fix it
no i get nothing by running lsof
ok well if you've fixed it then all good 👍
my bad i could not fix it
i think it is with the docker
try
docker run --rm -p 17839:80 nginx
i.e. some other random port that's very unlikely to be in useis it suppose to take long?
the container should start up pretty quickly? visit http://localhost:17839 in your browser when it's started and you should see the nginx hello world
Dachis-MacBook-Pro:~ dachilekborashvili$ docker run --rm -p 17839:80 nginx
docker: Error response from daemon: driver failed programming external connectivity on endpoint hopeful_gates (e777ca74d2296c695662ac9d30b4ae3d94d84b63040451a41508494bd9b27ead): Bind for 0.0.0.0:17839 failed: port is already allocated.
and you just ran that command the once?
i terminated the first one and ran again
do you get any output from
docker ps
?CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
62d69a2a3132 nginx "/docker-entrypoint.…" 5 minutes ago Up 5 minutes 0.0.0.0:17839->80/tcp hopeful_galileo
ok so the container is already running and bound to that port
presumably that link i sent you works on your machine and shows you the nginx hello world page?
yes
okay, so you can kill and remove that container (
docker rm -f 62d69a2a3132
)done
i checked its killed
so your docker install seems to be working fine, you can spin up and bind ports for containers, it's just convinced that something else is already using port 5432
so i should just use another port
cuz for some reason something is running on that port
if you can't find the culprit then yeah, i'd just use another port to get you going
you could always restart your machine and see whether that frees up the port too if you haven't already tried that
i just simply changed port it is running
@surf68@JohnStooberthanks both of you for your time and help