stacks-network / stacks-blockchain-docker

Stacks-blockchain with API using docker compose
GNU General Public License v3.0
29 stars 40 forks source link

Start fails due to postgres port in use #1

Closed friedger closed 4 years ago

friedger commented 4 years ago

It looks like the script tries to start postgres twice.

docker-compose up -d
WARNING: Some services (api, explorer, follower, miner, postgres) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.
Starting mocknet_bootstrap ... done
Starting mocknet_stacks-node-miner ... 
Starting mocknet_postgres          ... 
Starting mocknet_postgres          ... error

ERROR: for mocknet_postgres  Cannot start service postgres: driver failed programming external connectivity on endpoint mocknet_postgres (f2dStarting mocknet_stacks-node-miner ... done
 in use

ERROR: for postgres  Cannot start service postgres: driver failed programming external connectivity on endpoint mocknet_postgres (f2dd3b205a7e01981517b757aeccaf3aa2f25cec9ccda612d8f5a73cb3b4bad0): Error starting userland proxy: listen tcp 0.0.0.0:5432: bind: address already in use
ERROR: Encountered errors while bringing up the project.
wileyj commented 4 years ago

I'm thinking this is due to a port conflict, where 5432 is already in use on your local machine (docker-compose will attempt to open that port locally).

This will be addressed once I start documenting things, but you can edit the .env file locally: https://github.com/blockstack/stacks-local-dev/blob/master/.env#L31

In general, any env var named like xxxx_PORT_LOCAL can be changed to work on your local env.

I added this because I found myself checking the DB quite often for updates directly, but I'm open to removing this postgres local port being open. Thoughts?

friedger commented 4 years ago

lsof -i :5432 returns nothing docker container ls returns an empty table

Not sure which app could use the that port.

I very much like the open port, for debugging this should be helpful.

wileyj commented 4 years ago

can you share the logs of mocknet_postgres? docker logs mocknet_postgres

wileyj commented 4 years ago

actually, nm - i was able to reproduce. looking into it

wileyj commented 4 years ago

This is really confounding @friedger .... I was able to reproduce this once - but when it happened, i was also unable to run any new container. I had to kill -9 the hung process. i.e. docker run -it alpine sh hung indefinitely until i forced killed the pid.

Only after restarting docker did starting the above container work.

It's the first time I've seen behaviour like this - but I also did an update of docker last night. Can you check what version of docker you're running? It might be relevant to what you noticed.

$ docker --version
Docker version 19.03.13, build 4484c46d9d
friedger commented 4 years ago

I am running Docker version 19.03.8, build afacb8b7f0

wileyj commented 4 years ago

Did restarting docker daemon help here?

friedger commented 4 years ago

I found out that a postgres service is running. Stopping that helped. I am now able to run docker-compose.