Top Menu

Jump to content
Home
    • Projects
    • Work packages
    • News
    • Getting started
    • Introduction video
      Welcome to OpenProject
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Professional support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Create a new account
      Forgot your password?

Side Menu

  • Overview
  • Activity
  • Wiki
    • Table of contents
      • Expanded. Click to collapseCollapsed. Click to showWiki
        • Hierarchy leafModalität
        • Expanded. Click to collapseCollapsed. Click to showThemen
          • Hierarchy leaf00) Installation GNU/Linux in Virtualbox
          • Hierarchy leaf01) GNU/Linux Basics & Bash commandos
          • Hierarchy leaf02) Schulinternes APT Repository
          • Hierarchy leaf03) Fernwartung über SSH
          • Hierarchy leaf04) Prozesse und Systemd
          • Hierarchy leaf05) UFW
          • Hierarchy leaf06) MySQL
          • Hierarchy leaf07) Abfragen an die Mondial Datenbank
          • Hierarchy leaf08) PostgreSQL
          • Hierarchy leaf10) Crontab
          • Hierarchy leaf11) Wordpress
          • Expanded. Click to collapseCollapsed. Click to show12) Docker
            • Hierarchy leaf00) MySQL - Volumes - Ports ...
            • Hierarchy leaf01) PostgreSQL
            • Hierarchy leaf02) Docker-Compose
You are here:
  • Wiki
  • Themen
  • 12) Docker
  • 01) PostgreSQL

Content

01) PostgreSQL

  • More
    • Print
    • Table of contents

Postgresqldockerfile

#Baseimage
FROM ubuntu:18.04
#Paketquellen aktualisieren
RUN apt-get update
#Postgresql installieren -y -> ohne interaktion
RUN apt-get install -y postgresql
#Postgres soll auf Anfragen von allen Networkinterfaces hören
RUN sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /etc/postgresql/10/main/postgresql.conf
#Zugriff über das Dockernetzwer erlauben
RUN echo "host all all 172.17.0.1/32 md5" >> /etc/postgresql/10/main/pg_hba.conf
#Start postgresql service and sleep forever
CMD service postgresql start && sleep infinity

Bauen des Images

docker build -t postgresqlimage:latest -f Postgresldockerfile .

Gegenfalls container stoppen und löschen

#Stoppen
docker container stop postgresql
#Löschen
docker container rm postgresql

Volume für Container erstellen

docker volume create postgresqlvolume

Starten des containers

docker run -dit -v postgresqlvolume:/var/lib/postgresql -p 23456:5432 --name postgresql postgresqlimage:latest

In Container einsteigen, mit Datenbank verbinden und Benutzer anlegen

#In Container einsteigen
docker exec -it postgresql bash
#Als postgres Benutzer anmelden
su postgres
#Mit Datenbank verbinden
psql
#Benutzer anlegen
CREATE USER mondial with PASSWORD 'pwd';
#Datenbank anlegen
CREATE DATABASE Mondial;
#Berechtigung setzen
GRANT ALL PRIVILEGES ON DATABASE Mondial TO mondial;

PostgreSQL Client installieren auf Host System

sudo apt-get install postgresql-client

Verbinden mit Datenbank vom Host aus

psql --host=127.0.0.1 --port=23456 -U mondial -W
Loading...