Tech Blog‎ > ‎

Docker for Databases

posted Apr 2, 2016, 7:39 PM by Val Huber
You can use the Docker container for Postgres.

Create Docker

Under Docker Shell:

docker run --name some-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres 

later, you can stop it like this:

docker rm -f postgres

Important! Docker containers are code only - no persistence. This database loses all data, including tables, when you stop the container. It is therefore useful for demos and experiments, but not for production.  

Connect with Live API Creator

Connect like this:

Docker Database Images

MySQL

Versions available: 5.5, 5.6, 5.7

docker run --name MySQL56 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=Password1 -d mysql:5.6

Connecting

Host name: 192.168.99.100 (usually)

Port: 3306

User: root

Password: Password1

DB2

DB2 is different. You have to run a few manual commands. Leave the terminal open.

Version 10.5:

docker run --name DB2_10 -i -t -p 50000:50000 -e DB2INST1_PASSWORD=expresso123 -e LICENSE=accept ibmcom/db2express-c:latest bash

Then:

su - db2inst1
db2start
db2sampl

Connecting

Host name: 192.168.99.100 (usually)

Port: 3306

User: db2inst1

Password: expresso123

Database: SAMPLE

Oracle

Version 11gdocker run -d -p 1521:1521 wnameless/oracle-xe-11g

Connecting

Host name: 192.168.99.100 (usually)
Port: 1521
SID: xe
User: system
Password: oracle

PostgreSQL

Versions available: 9.1, 9.2, 9.3, 9.4, 9.5

docker run -d --name Postgres95 -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword postgres:9.5

Connecting
Host name: 192.168.99.100 (usually)
Port: 5432
Database: postgres
User: postgres
Password: mysecretpassword