PostgreSQL with Docker: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 14: Line 14:


=Running a Transient Instance=
=Running a Transient Instance=
Postgres binds by default on port 5432 and this is the port published by the following command:


<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
docker run posgres
docker run -p 5432:5432/tcp  posgres
</syntaxhighlight>
</syntaxhighlight>


The command will implicitly create a [[Docker_Storage_Concepts#Local_Volume_Driver|local]] [[Docker_Storage_Concepts#Anonymous_Volume|anonymous]] volume that will linger around after the container stops. The data on the anonymous local volume can be accessed by starting the stopped container.
The command will implicitly create a [[Docker_Storage_Concepts#Local_Volume_Driver|local]] [[Docker_Storage_Concepts#Anonymous_Volume|anonymous]] volume that will linger around after the container stops. The data on the anonymous local volume can be accessed by starting the stopped container.

Revision as of 16:57, 18 October 2018

Internal

Overview

A transient Posgres container instance can be started and exposed on a local host port as shown in the Running a Transient Instance section.

  • simplest image - data is lost
  • external volume
  • port mapping.

Running a Transient Instance

Postgres binds by default on port 5432 and this is the port published by the following command:

docker run -p 5432:5432/tcp  posgres

The command will implicitly create a local anonymous volume that will linger around after the container stops. The data on the anonymous local volume can be accessed by starting the stopped container.