It works for me. Below, I am using host.docker.internal to connect to the host’s localhost from within the container in which I install pgcli, to allow it to connect to the database container like if I were connecting from the host directly. (I hope Docker is not being smart about that.) But otherw… Answer from avbentem on forums.docker.com
🌐
GitHub
github.com › dencold › pgcli-docker
GitHub - dencold/pgcli-docker: Dockerized version of the cli tool for postgres · GitHub
Dockerized version of the cli tool for postgres. Contribute to dencold/pgcli-docker development by creating an account on GitHub.
Starred by 35 users
Forked by 14 users
Languages   Shell 83.9% | Dockerfile 16.1%
🌐
Docker Hub
hub.docker.com › r › pygmy › pgcli
pygmy/pgcli - Docker Image
or if you're using the official PostgreSQL docker image simply docker run -it --rm --link my-postgres-container:postgres pygmy/pgcli - it will pick up the variables you've set for your container (host, port, user, password)
🌐
GitHub
github.com › diyan › pgcli-docker
GitHub - diyan/pgcli-docker: pgcli in a tiny Docker image powered by Alpine Linux · GitHub
docker run --rm -ti --name=pgcli \ -e PGPASSWORD=secret \ --link=postgres:postgres \ diyan/pgcli \ --host=postgres \ --dbname=postgres \ --user=postgres
Starred by 9 users
Forked by 4 users
Languages   Dockerfile
🌐
PyPI
pypi.org › project › pgcli
pgcli · PyPI
$ docker run --rm -ti --net host pgcli pgcli -h localhost foo
      » pip install pgcli
    
Published   Jun 03, 2026
Version   4.5.0
Homepage   https://pgcli.com
🌐
GitHub
github.com › dbcli › pgcli
GitHub - dbcli/pgcli: Postgres CLI with autocompletion and syntax highlighting · GitHub
$ docker run --rm -ti --net host pgcli pgcli -h localhost foo
Starred by 13.3K users
Forked by 602 users
Languages   Python 98.1% | Gherkin 1.4%
🌐
GitHub
github.com › daxartio › pgcli-docker
GitHub - daxartio/pgcli-docker: Dockerized version of the pgcli tool for postgres
Dockerized version of the pgcli tool for postgres. Contribute to daxartio/pgcli-docker development by creating an account on GitHub.
Author   daxartio
🌐
Docker Hub
hub.docker.com › r › ingomuellernet › pgcli
ingomuellernet/pgcli - Docker Image
docker run --rm -it \ --link postgres-server \ -v /:/host/:ro \ -v $HOME/.config/pgcli/:/root/.config/pgcli/ \ ds3lab/pgcli -h postgres-server -U postgres Copy
🌐
Docker Community
forums.docker.com › docker hub
Can't connect to database by pgcli - Docker Hub - Docker Community Forums
August 13, 2022 - docker run -it \ -e POSTGRES_USER="root" \ -e POSTGRES_PASSWORD="root" \ -e POSTGRES_DB="ny_taxi" \ -v $(pwd)/ny_taxi_postgres_data:/var/lib/postgresql/data \ -p 5432:5432 \ postgres:13 Here is the command that I use to create database. When container has been created, another folder with similar ...
Find elsewhere
🌐
GitHub
github.com › danihodovic › pgcli-docker
GitHub - danihodovic/pgcli-docker: Pgcli dockerized · GitHub
Thin wrapper around pgcli (https://github.com/dbcli/pgcli). The default entrypoint is ["pgcli"]. docker run -it --rm --network container:$postgres_container_network danihodovic/pgcli -h postgres -U postgres
Author   danihodovic
🌐
Docker Hub
hub.docker.com › r › dbcliorg › pgcli › dockerfile
dbcliorg/pgcli Dockerfile
August 13, 2022 - FROM python:3.8-alpine RUN \ apk add --no-cache postgresql-libs && \ apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev && \ pip install pgcli==3.1.0 && \ apk --purge del .build-deps RUN mkdir /out VOLUME [ "/out" ] ENTRYPOINT ["pgcli"]Copy
🌐
GitHub
github.com › diyan › pgcli-docker › blob › master › Dockerfile
pgcli-docker/Dockerfile at master · diyan/pgcli-docker
pgcli in a tiny Docker image powered by Alpine Linux - diyan/pgcli-docker
Author   diyan
🌐
Docker Hub
hub.docker.com › r › diyan › pgcli
diyan/pgcli - Docker Image
Welcome to the world's largest container registry built for developers and open source contributors to find, use, and share their container images. Build, push and pull.
🌐
Manzanit0
manzanit0.github.io › automation › 2020 › 08 › 26 › bootstraping-postgres-greenfield.html
Bootstraping Postgres in your project
August 26, 2020 - POSTGRES_CONTAINER_NAME := memento-pg POSTGRES_PASSWORD := password PSQL_USER := docker PSQL_PASSWORD := 123 DATABASE_NAME := memento_db PROJECT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) pgcli: docker run -it --rm --network="host" dencold/pgcli postgresql://$(PSQL_USER):$(PSQL_PASSWORD)@localhost:5432/$(DATABASE_NAME) db: db-teardown db-start db-migrate db-start: docker pull postgres && \ docker run --rm --name $(POSTGRES_CONTAINER_NAME) \ -p 5432:5432 \ -e POSTGRES_PASSWORD=$(POSTGRES_PASSWORD) \ -v $(PROJECT_DIR)/scripts/db/:/docker-entrypoint-initdb.d \ -d postgres d
🌐
GitHub
github.com › dencold › pgcli-docker › blob › master › run-pgcli.sh
pgcli-docker/run-pgcli.sh at master · dencold/pgcli-docker
Dockerized version of the cli tool for postgres. Contribute to dencold/pgcli-docker development by creating an account on GitHub.
Author   dencold
🌐
Docker Hub
hub.docker.com › r › mribeiro › pgcli › dockerfile
mribeiro/pgcli Dockerfile
Search Docker Hub · K · Help · Back · System theme · Sign inSign up · Back · Back · By mribeiro•Updated about 9 years ago · Image · 2 · 824 · OverviewTags · FROM python:2.7-slim MAINTAINER Marcio Ribeiro <[email protected]> RUN apt-get -y update && apt-get -y install libpq-dev build-essential RUN pip install pgcli ENTRYPOINT ["pgcli"] Copy
🌐
Docker Hub
hub.docker.com › r › dencold › pgcli
dencold/pgcli - Docker Image
© 2025 Docker, Inc. All rights reserved. | Terms of Service | Subscription Service Agreement | Privacy | Legal
🌐
GitHub
github.com › chaifeng › docker-postgres-pgcli
GitHub - chaifeng/docker-postgres-pgcli · GitHub
docker run -it --name pgcli \ -e POSTGRES_DATABASE=your-dbname \ -e POSTGRES_HOST=your-postgres-container \ -e POSTGRES_USER=your-postgres-username \ -e POSTGRES_PASSWORD="your-postgres-password" \ --network your-network \ chaifeng/pgcli
Author   chaifeng
🌐
Docker Hub
hub.docker.com › r › frew › pgcli
Docker
Welcome to the world's largest container registry built for developers and open source contributors to find, use, and share their container images. Build, push and pull.
🌐
DevOps.dev
blog.devops.dev › postgresql-with-docker-from-setup-to-data-ingestion-and-pgadmin-integration-929c966cc650
PostgreSQL with Docker: From Setup to Data Ingestion and pgAdmin Integration | by Isioma Joy Efe | DevOps.dev
January 26, 2024 - To resolve this, change the port mapping for your PostgreSQL Docker container. Instead of the default port 5432, opt for an alternative port, such as 5431, by including -p 5431:5432 in your Docker run command. When connecting with pgcli, remember to use the new port, like this: pgcli -h localhost -p 5431 -u root -d ny_taxi_records.