-
-
Notifications
You must be signed in to change notification settings - Fork 17
testing with docker
Ryan Culpepper edited this page Jun 25, 2020
·
10 revisions
This page describes how to create testing environments (ie, database servers) using Docker.
References:
- https://hub.docker.com/_/postgres
- for scram-sha-256 authentication: https://github.com/docker-library/postgres/issues/726, https://github.com/docker-library/postgres/pull/713#issuecomment-614854429
- for TLS: https://github.com/docker-library/postgres/pull/152; that doesn't work, but easy to use snakeoil instead
docker pull postgresql
sudo docker run --name testdb-postgres --publish 5432:5432 \
-e POSTGRES_USER=rkt \
-e POSTGRES_PASSWORD=rktpwd \
-e POSTGRES_INITDB_ARGS=--auth-host=scram-sha-256 \
-e POSTGRES_HOST_AUTH_METHOD=scram-sha-256 \
postgres \
-c 'ssl=on' \
-c 'ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem' \
-c 'ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key'
# ... run tests ...
docker rm --force testdb-postgres
docker run --name testdb-postgres --publish 5432:5432 \
-e POSTGRES_USER=rkt \
-e POSTGRES_PASSWORD=rktpwd \
-e POSTGRES_INITDB_ARGS=--auth-host=scram-sha-256 \
-e POSTGRES_HOST_AUTH_METHOD=scram-sha-256 \
-d postgres \
-c 'ssl=on' \
-c 'ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem' \
-c 'ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key'
# ... run tests ...
docker rm --force testdb-postgres
The command above
References:
docker pull mysql
docker run --name testdb-mysql --publish 3306:3306 \
-e MYSQL_ROOT_PASSWORD=myrootpwd \
-e MYSQL_USER=rkt \
-e MYSQL_PASSWORD=rktpwd \
-e MYSQL_DATABASE=rkt \
-d mysql
# ... run tests ...
docker rm --force testdb-mysql
Note: latest version (8) defaults to caching-sha2-password, so client must connect with ssl=yes first.
docker pull mariadb
The server can be started using the same command as for mysql
, just replacing mysql
with mariadb
.
References:
- https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance (see README for instructions)
-
https://github.com/oracle/docker-images/blob/master/OracleDatabase/SingleInstance/FAQ.md
- for insufficient shared memory error on container startup
Building docker images:
git clone https://github.com/oracle/docker-images
cd docker-images/OracleDatabase/SingleInstance/dockerfiles
- get
oracle-xe-11.2.0-1.0.x86_64.rpm.zip
and put it in11.2.0.2
sudo ./buildDockerImage.sh -x -v 11.2.0.2
-
sudo ./buildDockerImage.sh -x -v 18.4.0
- This took a long time, so I gave up and interrupted it.
Installing Oracle ODBC libs on host:
docker run --name testdb-oracle --publish 1521:1521 --publish 5500:5500 \
-e ORACLE_PWD=orapwd \
--shm-size=1g \
-d oracle/database:11.2.0.2-xe
# ... run tests ...
docker rm --force testdb-oracle
References:
- https://hub.docker.com/r/ibmcom/db2
- https://www.ibm.com/support/pages/tech-tip-setting-unixodbc-driver-manager-and-odbc-environment-db2
- https://www.ibm.com/support/pages/howto-setup-odbc-application-connectivity-linux
docker pull ibmcom/db2
Setting up ODBC:
- https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.apdv.cli.doc/doc/t0061216.html
- https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.swg.im.dbclient.install.doc/doc/t0060690.html
- can avoid db2dsdriver.cfg by using connection string, eg
DRIVER=Db2;Database=testdb;Hostname=localhost;Port=50001;UID=db2inst1;PWD=db2pwd
docker run --name testdb-db2 -p 50000:50000 \
--privileged=true -e LICENSE=accept \
-e DB2INST1_PASSWORD=db2pwd \
-e DBNAME=testdb \
ibmcom/db2
# ... run tests ...
docker rm --force testdb-db2
References:
docker run --name testdb-ms --publish 1433:1433 \
-e 'ACCEPT_EULA=Y' \
-e 'SA_PASSWORD=abcdEFGH89!' \
-e 'MSSQL_PID=Express' \
mcr.microsoft.com/mssql/server