Sign inSign up

startx/sv-postgres

By startx

•Updated over 1 year ago

Container used to provide postgresql transactional database on fedora / centos / redhat

Image
1

10K+

startx/sv-postgres repository overview

⁠Docker OS Images : POSTGRESQL

STARTX Profile licence Sources last commit Build Status Top language Code size

Dockerhub Registry Docker postgres pulls Docker Repository on Quay

Startx postgres is a base container used for database services published in Dockerhub registry⁠. This container contain :

  • fedora system envelope
  • core OS rpm (kernel, libs) updated every week
  • fundamentals tools (ex: pwgen, tar, zip) updated every week
  • Postgresql SQL server and fundamentals modules (postgres release depend on the flavour you use, read down for more information)
  • usefull tools (psmisc, procps, coreutils, findutils, wget, curl, vi, bash-completion) only for the :latest and :devel flavour.

You can use Startx Postgresql image in many ways :

See more databases builders and sample on startx docker images repository⁠

⁠Container flavours

⁠Running this image

If you want to be guided on setting-up and installing various containers engines (docker⁠, podman⁠, s2i⁠, dockerEE⁠, kubernetes⁠, openshift⁠) you can read ours containers engines guidelines⁠.

⁠Running using docker
docker run -it -p 9241:5432 --name="example-postgres" startx/sv-postgres
  • Connect to your local database
pgsql -h localhost -P 9241
⁠Running using docker-compose
  • Create a docker-compose.yml file with the following content
postgres:
  image: startx/sv-postgres:latest
  container_name: "example-postgres"
  • Connect to your local database
pgsql -h localhost -P 9241
  • Execute the following command
docker-compose up -d
docker-compose logs
⁠Using this image as Openshift Build image
⁠Openshift images streams

Openshift cluster administrator can offer this image and all its flavour to all consumers. You can import our openshift images stream⁠ in your openshift project.

You must be cluster-admin to add this image to the openshift project. If not, you can add it to your own project (skip the oc project openshift command in the next script)

# swith to the openshift project
oc project openshift
# Add image streams to the service catalog (project or cluster-wide scope)
oc create -f https://raw.githubusercontent.com/startxfr/docker-images/master/Services/postgres/openshift-imageStreams.yml
⁠Openshift builder template

Openshift cluster administrator can add 2 build and deploy template to their consumers. As an administrator, you can import our openshift ephemeral builder template⁠ as well as our openshift persistent builder template⁠ in your openshift project.

You must be cluster-admin to add this image to the openshift project. If not, you can add it to your own project (skip the oc project openshift command in the next script)

# swith to the openshift project
oc project openshift
# Add this ephemeral template to the service catalog (project or cluster-wide scope)
oc create -f https://raw.githubusercontent.com/startxfr/docker-images/master/Services/postgres/openshift-template-build.yml
# Add this persistent template to the service catalog (project or cluster-wide scope)
oc create -f https://raw.githubusercontent.com/startxfr/docker-images/master/Services/postgres/openshift-template-build-persistent.yml

You can then build a database

# create an example project
oc new-project example
# start a new ephemeral database
oc process -f startx-postgres-build-template \
    -p APP_NAME=mydb-e \
| oc create -f -
# start a new persistent database
oc process -f startx-postgres-build-persist-template \
    -p APP_NAME=mydb-p \
| oc create -f -
⁠Openshift deploy template

Openshift cluster administrator can add a deploy template to their consumers. As an administrator, you can import our openshift deploy template⁠ as well as our openshift persistent deploy template⁠ in your openshift project.

You must be cluster-admin to add this image to the openshift project. If not, you can add it to your own project (skip the oc project openshift command in the next script)

# swith to the openshift project
oc project openshift
# Add this ephemeral template to the service catalog (project or cluster-wide scope)
oc create -f https://raw.githubusercontent.com/startxfr/docker-images/master/Services/postgres/openshift-template-deploy.yml
# Add this persistent template to the service catalog (project or cluster-wide scope)
oc create -f https://raw.githubusercontent.com/startxfr/docker-images/master/Services/postgres/openshift-template-deploy-persistent.yml

You can then deploy a database

# create a example project
oc new-project example
# start a new ephemeral database
oc process -f startx-postgres-deploy-template \
    -p APP_NAME=mydb-e \
| oc create -f -
# start a new persistent database
oc process -f startx-postgres-deploy-persist-template \
    -p APP_NAME=mydb-p \
| oc create -f -
⁠Using this image as S2I builder

Create your local project (skip if you already are in a project diretory with a run bash script)

# Create a project directory
mkdir example-project
cd example-project
# create a run script
cat << "EOF"
DROP TABLE IF EXISTS `sample`;
CREATE TABLE `sample` (
  `id` int(4) unsigned NOT NULL AUTO_INCREMENT,
  `key` varchar(128) NOT NULL DEFAULT '',
  `val` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `sample` VALUES (1,'version','0.0.1');
EOF > schema-sample.sql

Then you can use this image as an s2i builder image

# With your current directory database code
s2i build . startx/sv-postgres:latest startx-postgres-mydb
docker run --rm -d -p 9241:5432 startx-postgres-mydb
# With startx database sample code repository
s2i build https://github.com/startxfr/docker-images-example-postgres startx/sv-postgres startx-postgres-sample
docker run --rm -d -p 9241:5432 startx-postgres-sample
⁠Using this image as base container

You can use this Dockerfile template to start a new personalized container based on this container. Create a file named Dockerfile in your project directory and copy this content inside. See docker guide⁠ for instructions on how to use this file.

FROM startx/sv-postgres:latest
#... your container specifications

⁠Environment variable

VariableTypeDefaultDescription
SX_VERSIONstringlatestcontainer version
SX_TYPEstringserviceContainer family (os, service, application). could be enhanced
SX_SERVICEstringpostgresDefine the type of service or application provided
SX_IDautostartx/sv-postgresContainer ID coresponding to the image repository
SX_NAMEautoyesContainer name
SX_SUMMARYautoyesContainer purpose description
SX_VERBOSEboolnoDisplay information about the execution
SX_DEBUGboolnoDisplay debug informations during execution
APP_PATHstring/appPath to the application
LOG_PATHstring/var/log/httpdDestination path to the log produced by the webserver
LOADSQL_PATHstring/tmp/sqlPath for sql script to use when initializing database
SX_S2IDIRstring/tmpDestination path to the application pushed via s2i process

⁠For advanced users

You can contribute or start this container initiative locally. Follow theses instructions⁠ to setup a working environment.

This section will help you if you want to :

  • Get latest version of this container Service source code
  • Enhance and share your container improvement by adding instruction in Dockefile
⁠Build & run a container using docker
  1. Jump into the container directory with cd Services/postgres
  2. Build the container using docker build -t startx-postgres .
  3. Run this container
    • Interactively with docker run -it startx-postgres. If you add a second parameter (like /bin/bash) to will run this command instead of the default entrypoint. Usefull to interact with this container (ex: /bin/bash, /bin/ps -a, /bin/df -h,...)
    • As a daemon with docker run -d -p 9241:5432 startx-postgres
⁠Build & run a container using docker-compose
  1. Jump into the container directory with cd Services/postgres
  2. Run this container
    • Interactively with docker-compose up Startup logs appears and escaping this command stop the container
    • As a daemon with docker-compose up -d. Container startup logs can be read using docker-compose logs

Tag summary

Content type

Image

Digest

sha256:ce2e9088d…

Size

139.8 MB

Last updated

over 1 year ago

docker pull startx/sv-postgres