Start PostgreSQL in docker image

We use phusion/baseimage-docker container for minimal Ubuntu image:

# docker create --name postgresql phusion/baseimage-docker

Install PostgreSQL in container:

# docker exec -ti postgresql
# apt-get update && apt-get install postgresql postgresql-contrib

Create startup script:

# mkdir /etc/service/postgres
# echo '#!/bin/sh' > /etc/service/postgres/run
# echo 'exec /sbin/setuser postgres /usr/lib/postgresql/9.5/bin/postgres -D /etc/postgresql/9.5/main --config-file=/etc/postgresql/9.5/main/postgresql.conf' >> /etc/service/postgres/run
# chown root /etc/service/postgres/run
# chmod a+x /etc/service/postgres/run
Content type
file
Вложение Размер
Place this file into /etc/service/postgres/run 493 байта