Git Product home page Git Product logo

pgcli-docker's Introduction

pgcli-docker

Dockerized version of the pgcli tool for postgres.

Screenshot.gif

Quick usage

  1. Pull the docker image: docker pull dencold/pgcli
  2. Run the container: docker run -it --rm dencold/pgcli DB_URL
  3. Or, if you already have a postgres container, you can just do this: docker run -it --link my-postgres:postgres --rm dencold/pgcli

Note that DB_URL is in the format of:

postgresql://user:password@host:port/dbname

For more information on database connection strings, see the postgres documentation.

For other run options, see the "Running" section, below.

Why a docker version?

Installing pgcli is a fairly straightforward process, as long as you already have postgres installed, you can generally get away with a straight pip install, however there are some gotchas. For example, on linux there are a host of other dependencies, from the pgcli installation guide:

Pgcli uses psycopg to talk to postgres database. In order to install psycopg, you will need libpq and python-dev installed on your system. Since psycopg is a C extension for Python, a C compiler is needed to install it on your system.

If you are already using docker, life can be a lot easier. You are a simple pull away from getting pgcli on whatever environment you are running:

docker pull dencold/pgcli

There are a number of additional benefits of using a docker container, we'll see these in the next section...

Running

I generally run my development apps with a separate container for the postgres database. Hooking up the database to the application is achieved via docker links. In order to make it easy to use pgcli on any postgres container, I've made a simple docker wrapper for the command. It is smart about pulling in the linked postgres environment variables and makes it easy to use on your own instances.

If you have one of these postgres containers already running, all you need to do is link the postgres container to pgcli. For example, if your postgres container was named my-postgres, you can attach pgcli with this one-liner:

docker run -it --link my-postgres:postgres --rm dencold/pgcli

It will determine host, port, and login details directly from the linked postgres container's environment variables. You should be dropped right into a pgcli session without the need to type in any credentials. Awesomesauce!

Version Notes

This package used to pin pgcli's version to guarantee combatibility, but that's no longer the case. The docker container is created using pip install pgcli so you'll automatically get the latest version of the tool when you run your docker pull.

pgcli-docker's People

Contributors

amjith avatar dencold avatar mightyguava avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pgcli-docker's Issues

Postgres image is on a different network

Usually the postgres instance is not spun up on the default network but a network defined as db.

Is there a command/way to access the network and using the pgcli.

Great product btw

I get the following:

$ docker network ls
NETWORK ID          NAME                              DRIVER              SCOPE
1c539db56953        starter_default                   bridge              local


$ docker run -it --link starter_db_1:postgres --rm dencold/pgcli                
docker: Error response from daemon: Cannot link to /starter_db_1, as it does not belong to the default network.

This seems to solve it but I am not sure how I should be able to do it
https://stackoverflow.com/a/36489937/3767229

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.