{"id":15187207,"url":"https://github.com/kovalenkovpu/postgres-docker","last_synced_at":"2026-03-02T12:38:30.584Z","repository":{"id":194971516,"uuid":"691936237","full_name":"kovalenkovpu/postgres-docker","owner":"kovalenkovpu","description":"Setup example for postgres and pgAdmin within Docker","archived":false,"fork":false,"pushed_at":"2023-09-15T13:37:16.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-08T09:52:38.306Z","etag":null,"topics":["docker","docker-postgresql","docker-psql","postgresql","psql","psql-database"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kovalenkovpu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-15T07:50:49.000Z","updated_at":"2023-09-15T13:39:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"923d2af1-6b18-41b7-b871-8a452728d510","html_url":"https://github.com/kovalenkovpu/postgres-docker","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.5,"last_synced_commit":"6a0d75256237af8ac55218927323e6491605b2ae"},"previous_names":["kovalenkovpu/postgres-docker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovalenkovpu%2Fpostgres-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovalenkovpu%2Fpostgres-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovalenkovpu%2Fpostgres-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kovalenkovpu%2Fpostgres-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kovalenkovpu","download_url":"https://codeload.github.com/kovalenkovpu/postgres-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240746950,"owners_count":19850996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-postgresql","docker-psql","postgresql","psql","psql-database"],"created_at":"2024-09-27T18:04:20.566Z","updated_at":"2026-03-02T12:38:25.537Z","avatar_url":"https://github.com/kovalenkovpu.png","language":null,"readme":"# How to work with Postgres in Docker\n\n\u003e Take a look into `.env` and `compose.yaml` files for the details on each setting and each env variable\n\n### Prerequisites\n\n- Docker is installed on your computer\n- Copy the content of `.env.example` to the `.env` file\n\n### Run docker service locally, then run the compose\n\n\u003e `docker compose up`\n\nYou shall see docker containers pulling 2 images: `pgadmin` and `postgres` respectively. `pgadmin` is not necessary, but just in case you prefer to work with databases in a visual manner\n\nThen, that's how the successful start of the containers looks like:\n\n```\n[+] Running 3/3\n ✔ Network docker-pg_default  Created              0.0s\n ✔ Container postgres         Created              0.3s\n ✔ Container pgadmin          Created              0.3s\n```\n\n### Working with `pgadmin` within Docker\n\n1. Open `localhost:5050` in your browser and login with the `pgadmin` credentials specified in the `.env` file\n2. Register new server:\n   - General. Name: any name you prefer\n   - Connection. Host name/address: `host.docker.internal`\n   - Connection. Port: port as specified in your `compose.yaml` - `services.postgres.ports`\n   - Connection. Database: as specified in `.env` - `POSTGRES_DB`\n   - Connection. Password: as specified in `.env` - `POSTGRES_PW`\n\nNow you can find your server in the `pgadmin` Object Explorer\n\n### Connect to Postgres within Docker\n\nIn a terminal, type:\n\n\u003e `docker exec -it \u003cCONTAINER_NAME | CONTAINER_ID\u003e psql -U \u003cPOSTGRES_USER\u003e \u003cPOSTGRES_DB\u003e`\n\n- `CONTAINER_NAME` as specified in your `compose.yaml` file (`services.postgres.container_name`), or\n- `CONTAINER_ID` is obtained using the command: `docker ps`\n\n### Connect to your DB within Docker Postgres\n\n[Simple an clear tutorial for psql commands](https://www.tutorialspoint.com/postgresql/index.htm)\n\nTo see all available DBs:\n\n\u003e `\\l`\n\nSelect your DB (its name is specified in `.env` file under the name `POSTGRES_DB`):\n\n\u003e `\\c \u003cPOSTGRES_DB\u003e`\n\nList all tables:\n\n\u003e `\\d`\n\nCreate temporary table:\n\n```\nCREATE TABLE COMPANY(\n   ID INT PRIMARY KEY     NOT NULL,\n   NAME           TEXT    NOT NULL,\n   AGE            INT     NOT NULL,\n   ADDRESS        CHAR(50),\n   SALARY         REAL\n);\n```\n\nDrop the table:\n\n\u003e `DROP TABLE COMPANY;`\n\nTo quit:\n\n\u003e `\\q`\n\n### To remove volumes (remove all DB data)\n\n`docker-compose down --volumes`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkovalenkovpu%2Fpostgres-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkovalenkovpu%2Fpostgres-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkovalenkovpu%2Fpostgres-docker/lists"}