I was learning laravel based on a certain learning material, and it was the content to start the container using PostgreSQL, but since it did not start well, it is a memorandum until error resolution.
Terminal
docker-compose up -d workspace php-fpm nginx postgres
It is an option after up, but the postgres attached at the end will be the story this time.
If the container is started successfully,
Terminal
Creating laravel-sns_docker-in-docker_1 ... done
Creating laravel-sns_workspace_1 ... done
Creating laravel-sns_php-fpm_1 ... done
Creating laravel-sns_nginx_1 ... done
Creating laravel-sns_porstgres_1 ... done
It should come out like this, but in my case
Terminal
Recreating laravel-sns_postgres_1 ... error
Creating laravel-sns_docker-in-docker_1 ... done
Creating laravel-sns_workspace_1 ... done
Creating laravel-sns_php-fpm_1 ... done
Creating laravel-sns_nginx_1 ... done
ERROR: for laravel-sns_postgres_1 Cannot start service postgres: Ports are not available: listen tcp 0.0.0.0:5432: bind: address already in use
It looks like this.
A few months ago, I found out that it was postgres that I had installed when I didn't know much more than it is now.
At that time, I remembered the existence of postgres that I installed without thinking because I wanted to use a DB other than MySQL, and when I looked at the connection status from pgadmin, the port number 5432 shown in this error content was connected It was in a state.
This time it was an error that occurred while learning a certain teaching material, so when I consulted with the instructor, ・ Ports are not available ・ Address already in use Why don't you search around with keywords? I got the advice, so
Ports are not available → Ports are not available address already in use → The address has already been used Based on the interpretation of the literal translation, I searched and found a hint that seems to be this.
Articles that I was able to refer to https://mebee.info/2020/04/20/post-7968/
Is it possible to kill the process using port number 5432 based on this? I thought and executed immediately
Terminal
sudo lsof -i -P | grep 5432
pgAdmin4 2471 --------- 21u IPv6 --------- 0t0 TCP localhost:64447->localhost:5432 (CLOSE_WAIT)
* Account names and tokens are hidden.
Now that we know that the process number was 2471,
Terminal
kill 2471
Execute the kill command with
Start the container again
Terminal
docker-compose up -d workspace php-fpm nginx postgres
Omit the started container
Starting 8d38216de390_laravel-sns_postgres_1 ... done
I was able to start postgres safely.
When I think about it, I was reminded that postgres, which I had only installed at that time and had never used, was already connected to the server.
I knew the horror of installing this even in an ignorant state, but at that time I didn't even know the kill command at all, so I learned that there are some things that can be solved over time.
It's not a big deal, but if there is even one person in the same situation, it may be useful for something.
Recommended Posts