Tag: postgresql

Specifying superuser PostgreSQL password for a Docker Container

When running a PostgreSQL database in a Docker container, the documentation for the official PostgreSQL Docker Image specifies that the administrator password should be set in an environmental variable like: docker run –name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres For those that do not want to hard-code a plain-text password in their scripts, are there more […]

How do I create a docker-compose version 2 to have a persistent postgres db using volumes?

I understand that using the older version of docker-compose, we can create another container with just a data volume and link it using volumes_from to make it a “data-only container.” However, I wanted to test out using the new syntax. version: ‘2’ services: app: build: . links: – psql psql: image: postgres volumes_from: – psqldata […]

Docker Backup and restore postgres

I using docker postgres:9.4 image. I need to know how to backup and restore volume only container. Created Volume container: docker run -v /var/lib/postgresql/data –name dbdata postgres:9.4 /bin/true Using the volume docker run –name=postgres –volumes-from=dbdata -d -p 6432:5432 postgres:9.4 Backup Volume container docker run –volumes-from dbdata -v $(pwd):/backup postgres:9.4 tar cvf /backup/backup.tar /var/lib/postgresql/data Restore volume […]

Run postgres container with data volumes through docker-machine

I have an issue with running postgres container with set up volumes for data folder on my Mac OS machine. I tried to run it such like this: docker run \ –name my-postgres \ -e POSTGRES_USER=admin \ -e POSTGRES_PASSWORD=password \ -e POSTGRES_DB=some_db_dev \ -v $PG_LOCAL_DATA:/var/lib/postgresql/data \ -d postgres:9.5.1 Every time I got the following result […]

Extending docker official postgres image

I’m trying to extend the official docker postgres image in order to install a custom python module so I can use it from withing a plpython3 stored procedure. Here’s my dockerfile FROM postgres:9.5 RUN apt-get update && apt-get install -y postgresql-plpython3-9.5 python3 ADD ./repsug/ /opt/smtnel/repsug/ WORKDIR /opt/smtnel/repsug/ RUN [“python3”, “setup.py”, “install”] WORKDIR / My question […]

Docker & Postgres: Failed to bind tcp address already in use

Problem I’m trying to start postgres in a docker container on my Mac, but I keep getting the following error message docker: Error response from daemon: driver failed programming external connectivity on endpoint postgres (8392b9e5cfaa28f480fe1009dee461f97e82499726f4afc4e916358dd2d2f61e): Error starting userland proxy: Failed to bind tcp address already in use. I have postgres installed locally, but I […]

How to use Postgresql container with existing data?

I am trying to set up postgresql container (https://hub.docker.com/_/postgres/). I have some data from current postgres instance. I copied it from /var/lib/postgresql/data and want to set it as a volume to postgres container. My part from docker-compose.yml file about postgres: db: image: postgres:9.4 ports: – 5432:5432 environment: POSTGRES_PASSWORD: postgres POSTGRES_USER: postgres PGDATA : /var/lib/postgresql/data volumes: […]

Creating a table in single user mode in postgres

Im trying to create a Dockerfile from the postgres image. The repo says that initialization should be handled by placing a shell script in /docker-entrypoint-initdb.d/. I put the following script based on an example I found online: #!/bin/bash echo “******CREATING DOCKER DATABASE******” gosu postgres postgres –single <<- EOSQL CREATE DATABASE orpheus; CREATE USER docker WITH […]

Docker – How can run the psql command in the postgres container?

I would like to use the psql in the postgres image in order to run some queries on the database. But unfortunately when I attach to the postgres container, I got that error the psql command is not found… For me a little bit it is a mystery how I can run postgre sql queries […]

Dockerizing PostgreSQL – psql Connection refused

I’m playing around with Docker and I would like to Dockerize a Postgres container. I’m following the official example but I can not connect to the image running using psql. I created the Dockerfile with the content of the example. I builded an image from the Dockerfile and assigned it a name. Then I run […]

Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.