-
-
Notifications
You must be signed in to change notification settings - Fork 17
testing with docker
Ryan Culpepper edited this page Jun 24, 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 --rm --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 --rm --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 --rm --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.