Buradasın
Running PSQL in Docker Postgres Container
stackoverflow.com/questions/37099564/docker-how-can-run-the-psql-command-in-the-postgres-containerYapay zekadan makale özeti
- Basic Methods
- Use docker exec -it to run commands in running containers
- Open bash terminal using docker exec -it container_name bash
- Connect to container using psql -U username -W password
- Alternative Approaches
- Access container through docker-compose using service name
- Connect directly to host using psql client on ports:
- Use row_to_json function for readable output
- Create separate service for running queries at startup
- Configuration Details
- Container name or ID can be used instead of service name
- -d flag is equivalent to specifying database name as first non-option
- -i flag needed for database restore in containers