|
| 1 | +# Containers |
| 2 | + |
| 3 | +Containers here are ment to be used for running tests. When built correctly after run they will have required database structure. |
| 4 | +Dockerfiles and initialization scripts are grouped into folders and hereafter all examples of build commands assume that they are executed in context of one of the folders. |
| 5 | + |
| 6 | +Across all instances of different RDBMSs we use 'dotest' user with 'dotest' password as cridentials for connection. In some cases user can be changed on container run, but not in all cases. We recommend using default settings, thought test connection password is weak it is fine for test environment and easy to remember. |
| 7 | + |
| 8 | +## MS SQL Server |
| 9 | + |
| 10 | +Dockerfiles are placed in 'mssql' folder. |
| 11 | + |
| 12 | +### Build image |
| 13 | + |
| 14 | +Assuming commands are executed in context of 'mssql' folder, images can be built as following |
| 15 | + |
| 16 | +```console |
| 17 | +docker buildx build -f do-mssql-2017 -t do-mssql:2017 . |
| 18 | +``` |
| 19 | +```console |
| 20 | +docker buildx build -f do-mssql-2019 -t do-mssql:2019 . |
| 21 | +``` |
| 22 | + |
| 23 | +Don't forget about the dot at the end. |
| 24 | + |
| 25 | +More information about ```buildx build``` [in docker documentation](https://docs.docker.com/reference/cli/docker/buildx/build/). |
| 26 | + |
| 27 | +### Run container |
| 28 | + |
| 29 | +If images are built like in the examples above then containers can be run like so |
| 30 | + |
| 31 | +```console |
| 32 | +docker run --name DO_SQL2017 -h DO_SQL2017 -e ACCEPT_EULA=Y -e MSSQL_PID="Developer" -e MSSQL_SA_PASSWORD="<your sa password>" -e TZ=<timezone of host> -e MSSQL_INIT_WAIT=60 -p 1417:1433 -d do-mssql:2017 |
| 33 | +``` |
| 34 | +```console |
| 35 | +docker run --name DO_SQL2019 -h DO_SQL2019 -e ACCEPT_EULA=Y -e MSSQL_PID="Developer" -e MSSQL_SA_PASSWORD="<your sa password>" -e TZ=<timezone of host> -e MSSQL_INIT_WAIT=60 -p 1419:1433 -d do-mssql:2019 |
| 36 | +``` |
| 37 | + |
| 38 | +Here, |
| 39 | + |
| 40 | +``` --name``` - name of the container, we use names like in the examples but you can choose any other name. |
| 41 | + |
| 42 | +``` -h``` or ```--hostname``` - it will be required in connection strings, if you are familiar with MS SQL Server installation process then you probably know about named instances. The hosthame here will be name of instance. |
| 43 | + |
| 44 | +``` -e ACCEPT_EULA=Y ``` - accepting EULA, more on [official docker page](https://hub.docker.com/r/microsoft/mssql-server) |
| 45 | + |
| 46 | +``` -e MSSQL_PID="Developer"``` - the edition the container will run with. We develop so we use "Developer" edition (available options listed on [official docker page](https://hub.docker.com/r/microsoft/mssql-server) ) |
| 47 | + |
| 48 | +``` -e MSSQL_SA_PASSWORD="<your sa password>" ``` - password for 'sa' user. It should meet MS SQL Server password policies. (more on [official docker page](https://hub.docker.com/r/microsoft/mssql-server) ) |
| 49 | + |
| 50 | +``` -e TZ=<timezone of host>``` - Some of tests still assume that test runner and storage insance are in the same timezone. If you run and test locally on your machine, set it to host timezone, otherwise false falling tests appear. |
| 51 | + |
| 52 | +``` -e MSSQL_INIT_WAIT=60 ``` - NOTE, this is not a standard variable. MS SQL Server takes some time to start and begin recieving connections, to not get false connection errors we need to wait for some time. This parameter defines how long we need to wait before first attempt to connect. Depending on how performant host machine is the value might require increase or let be decreased. Default wait time is 60 (seconds). |
| 53 | + |
| 54 | +``` -p 1417:1433``` - host-to-container port mappings. If serveral containers are run on the same host they are required to have different host ports. We use following pattern - first two digits of default port (1433) and last two digits of MS SQL Server version e.g. 17 for 2017, 19 for 2019, so on. |
| 55 | + |
| 56 | + |
| 57 | +### Connect to instance in docker |
| 58 | + |
| 59 | +To access an instance run in docker use "```<pc name or ip>\hostname, <host port>```" as ```DataSource```, similar to connections to named instances. |
| 60 | + |
| 61 | +Say, Docker's host has name is "WILLY" and containers run with commands above, then connection strings may look like: |
| 62 | + |
| 63 | +``` |
| 64 | +Data Source=WILLY\DO_SQL2017,1417;Initial Catalog=DO-Tests;User Id=dotest;Password=dotest;MultipleActiveResultSets=True; |
| 65 | +``` |
| 66 | +``` |
| 67 | +Data Source=WILLY\DO_SQL2019,1419;Initial Catalog=DO-Tests;User Id=dotest;Password=dotest;MultipleActiveResultSets=True; |
| 68 | +``` |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +## PostgreSQL |
| 73 | + |
| 74 | +Dockerfiles are placed in 'postgres' folder. |
| 75 | + |
| 76 | +### Build image |
| 77 | + |
| 78 | +Assuming commands are executed in context of 'postgres folder, images can be built with following commands |
| 79 | + |
| 80 | +```console |
| 81 | +docker buildx build -f do-postgre-9_0 -t do-postgres:9.0 . |
| 82 | +``` |
| 83 | +```console |
| 84 | +docker buildx build -f do-postgre-9_1 -t do-postgres:9.1 . |
| 85 | +``` |
| 86 | +```console |
| 87 | +docker buildx build -f do-postgre-9_2 -t do-postgres:9.2 . |
| 88 | +``` |
| 89 | +```console |
| 90 | +docker buildx build -f do-postgre-9_6 -t do-postgres:9.6 . |
| 91 | +``` |
| 92 | +```console |
| 93 | +docker buildx build -f do-postgre-10 -t do-postgres:10.0 . |
| 94 | +``` |
| 95 | +```console |
| 96 | +docker buildx build -f do-postgre-11 -t do-postgres:11.0 . |
| 97 | +``` |
| 98 | + |
| 99 | + |
| 100 | +NOTE Images older than 9.6 are unable to update tzdata so some tests can fail due to specific way of working with offset on ```TIMESTAMP WITH TIMEZONE```. |
| 101 | + |
| 102 | + |
| 103 | +### Run container |
| 104 | + |
| 105 | +Assuming the images are built like in examples above containers can be run like so |
| 106 | + |
| 107 | +```console |
| 108 | +docker run --name postgre-9.0 -e POSTGRES_PASSWORD=<your password> -e POSTGRES_HOST_AUTH_METHOD=md5 -e TZ=<timezone of host> -p 5490:5432 -d do-postgres:9.0 |
| 109 | +``` |
| 110 | +```console |
| 111 | +docker run --name postgre-9.1 -e POSTGRES_PASSWORD=<your password> -e POSTGRES_HOST_AUTH_METHOD=md5 -e TZ=<timezone of host> -p 5491:5432 -d do-postgres:9.1 |
| 112 | +``` |
| 113 | +```console |
| 114 | +docker run --name postgre-9.2 -e POSTGRES_PASSWORD=<your password> -e POSTGRES_HOST_AUTH_METHOD=md5 -e TZ=<timezone of host> -p 5492:5432 -d do-postgres:9.2 |
| 115 | +``` |
| 116 | +```console |
| 117 | +docker run --name postgre-9.6 -e POSTGRES_PASSWORD=<your password> -e POSTGRES_HOST_AUTH_METHOD=md5 -e TZ=<timezone of host> -p 5496:5432 -d do-postgres:9.6 |
| 118 | +``` |
| 119 | +```console |
| 120 | +docker run --name postgre-10 -e POSTGRES_PASSWORD=<your password> -e POSTGRES_HOST_AUTH_METHOD=md5 -e TZ=<timezone of host> -p 54100:5432 -d do-postgres:10.0 |
| 121 | +``` |
| 122 | +```console |
| 123 | +docker run --name postgre-11 -e POSTGRES_PASSWORD=<your password> -e POSTGRES_HOST_AUTH_METHOD=md5 -e TZ=<timezone of host> -p 54110:5432 -d do-postgres:11.0 |
| 124 | +``` |
| 125 | + |
| 126 | +Here, |
| 127 | + |
| 128 | +``` --name postgre-17``` - name of the container |
| 129 | + |
| 130 | +```-e POSTGRES_PASSWORD=<your password>``` - superuser password, required by base image. |
| 131 | + |
| 132 | +```-e POSTGRES_HOST_AUTH_METHOD=md5``` - option that controlls 'auth-method'. For test purposes 'md5' is ok. |
| 133 | + |
| 134 | +```-e TZ=<timezone of host>``` - Some of tests still assume that test runner and storage insance are in the same timezone. If you run and test locally on your machine, set it to host timezone, otherwise false falling tests appear. |
| 135 | + |
| 136 | +```-p 54110:5432``` - host-to-container port mappings. If serveral containers are run on the same host they require to have different ports. We use following pattern - first two digits of standard port (5432) and PostgreSQL version after that e.g. 110 for 11.0, 96 for 9.6. |
| 137 | + |
| 138 | + |
| 139 | +During first run of container database structure and users will be created. By default it creates 'dotest' user, 'dotest' database with several schemas within. |
| 140 | +We intentionally don't use superuser as owner of database and user for connections, if you change superuser name by using ```POSTGRES_USER``` variable, don't name it 'dotest', otherwise conflict will occur. |
| 141 | + |
| 142 | + |
| 143 | +More information about standard options [on official image page on docker hub](https://hub.docker.com/_/postgres) |
| 144 | + |
| 145 | + |
| 146 | +### Connect to instance in docker |
| 147 | + |
| 148 | +To access an instance run in docker use host name and the port you have mapped container to. If we have docker on the same "WILLY" host then connection strings may look like: |
| 149 | + |
| 150 | +``` |
| 151 | +HOST=WILLY;PORT=5490;DATABASE=dotest;USER ID=dotest;PASSWORD=dotest; |
| 152 | +``` |
| 153 | +``` |
| 154 | +HOST=WILLY;PORT=5496;DATABASE=dotest;USER ID=dotest;PASSWORD=dotest; |
| 155 | +``` |
| 156 | +``` |
| 157 | +HOST=WILLY;PORT=54110;DATABASE=dotest;USER ID=dotest;PASSWORD=dotest; |
| 158 | +``` |
| 159 | + |
| 160 | +for containers postgre-9.0, postgre-9.6, postgre-11 respectively, you get the idea. |
| 161 | + |
| 162 | + |
| 163 | +# MySQL |
| 164 | + |
| 165 | +Dockerfiles are located in 'mysql' folder. |
| 166 | + |
| 167 | +### Build image |
| 168 | + |
| 169 | +Assuming commands are executed in context of 'mysql' folder, images can be built with following commands |
| 170 | + |
| 171 | + |
| 172 | +```console |
| 173 | +docker buildx build -f do-mysq-5_5 -t do-mysql:5.5 . |
| 174 | +``` |
| 175 | +```console |
| 176 | +docker buildx build -f do-mysq-5_6 -t do-mysql:5.6 . |
| 177 | +``` |
| 178 | + |
| 179 | + |
| 180 | +### Run container |
| 181 | + |
| 182 | + |
| 183 | +```console |
| 184 | +docker run --name mysql-5.5 -p 3355:3306 -e MYSQL_ROOT_PASSWORD=<your password> -e MYSQL_DATABASE=dotest -e MYSQL_USER=dotest -e MYSQL_PASSWORD=dotest -d do-mysql:5.5 |
| 185 | +``` |
| 186 | +```console |
| 187 | +docker run --name mysql-5.6 -p 3356:3306 -e MYSQL_ROOT_PASSWORD=<your password> -e MYSQL_DATABASE=dotest -e MYSQL_USER=dotest -e MYSQL_PASSWORD=dotest -d do-mysql:5.6 |
| 188 | +``` |
| 189 | + |
| 190 | +Here, |
| 191 | + |
| 192 | +``` --name mysql-5.6``` - name of container, can be changed, affects nothing |
| 193 | + |
| 194 | +``` -p 3356:3306``` - host-to-container port mapping. We use following pattern - two first digits from default port (3306) folowed by version of MySQL e.g. 56 for MySQL 5.6. |
| 195 | + |
| 196 | +``` -e MYSQL_ROOT_PASSWORD=<your password>``` - root password, required by base image. |
| 197 | + |
| 198 | +``` -e MYSQL_DATABASE=dotest``` - database name to be created, can be changed (don't forget to change connection string) or omitted (initialization script will create 'dotest' database). |
| 199 | + |
| 200 | +``` -e MYSQL_USER=dotest```- user name to be created for connections, can be changed (don't forget to change connection string) or omitted (initialization script will create 'dotest' user with 'dotest' password). |
| 201 | + |
| 202 | +``` -e MYSQL_PASSWORD=dotest``` - password, required if MYSQL_USER is defined. |
| 203 | + |
| 204 | +More information about standard options [on official image page on docker hub](https://hub.docker.com/_/mysql) |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | +### Connect to instance in docker |
| 209 | + |
| 210 | +To access an instance run in docker use host name and port you have mapped container to. If we have docker on the same "WILLY" host then connection strings may look like: |
| 211 | + |
| 212 | +``` |
| 213 | +Server=WILLY;Port=3355;Database=dotest;Uid=dotest;Pwd=dotest;Default Command Timeout=120; |
| 214 | +``` |
| 215 | +``` |
| 216 | +Server=WILLY;Port=3356;Database=dotest;Uid=dotest;Pwd=dotest;Default Command Timeout=120; |
| 217 | +``` |
| 218 | + |
| 219 | + |
| 220 | + |
| 221 | +# Firebird |
| 222 | + |
| 223 | +Dockerfiles are located in 'firebird' folder. |
| 224 | + |
| 225 | +### Build image |
| 226 | + |
| 227 | +Assuming commands are executed in context of 'firebird' folder, image can be built with following commands |
| 228 | + |
| 229 | + |
| 230 | +```console |
| 231 | +docker buildx build -f do-firebird-3_0 -t do-firebird:3.0 . |
| 232 | +``` |
| 233 | + |
| 234 | + |
| 235 | +### Run container |
| 236 | + |
| 237 | +Assuming the image is built like in the example above container can be run like so |
| 238 | + |
| 239 | + |
| 240 | +```console |
| 241 | +docker run --name firebird-3 -p 3053:3050 -e FIREBIRD_ROOT_PASSWORD=<your password> -e FIREBIRD_USER=dotest -e FIREBIRD_PASSWORD=dotest -e FIREBIRD_DATABASE=DOTEST.fdb -e FIREBIRD_DATABASE_PAGE_SIZE=8192 -d do-firebird:3.0 |
| 242 | +``` |
| 243 | + |
| 244 | +Here, |
| 245 | + |
| 246 | +```--name firebird-3``` - name of contaner, you can choose different name, it doesn't really matter. |
| 247 | + |
| 248 | +```-e FIREBIRD_ROOT_PASSWORD=<your password>``` - root user password. |
| 249 | + |
| 250 | +```-e FIREBIRD_USER=dotest``` - user for connections, can be changed. |
| 251 | + |
| 252 | +```-e FIREBIRD_PASSWORD=dotest``` - user password. Required when user defined. |
| 253 | + |
| 254 | +```-e FIREBIRD_DATABASE=DOTEST.fdb``` - database file name to create. |
| 255 | + |
| 256 | +``` -e FIREBIRD_DATABASE_PAGE_SIZE=8192``` - page size for database. |
| 257 | + |
| 258 | +```-p 3053:3050``` - host-to-container port mapping. We use following pattern - first three digits of standard port (3050) and major version of Firebird, e.g. 3, 4 ,5. |
| 259 | + |
| 260 | +Pair ```FIREBIRD_USER``` / ```FIREBIRD_PASSWORD``` can be omitted, in this case initialization script will handle it and create 'dotest' user with 'dotest' password. |
| 261 | + |
| 262 | +More information about standard options [on official image page on docker hub](https://hub.docker.com/r/firebirdsql/firebird) |
| 263 | + |
| 264 | + |
| 265 | +### Connect to instance in docker |
| 266 | + |
| 267 | +To access an instance run in docker use host name and port you have mapped container to. If we have docker on the same "WILLY" host then connection string may look like: |
| 268 | + |
| 269 | +``` |
| 270 | +User=dotest;Password=dotest;Database=dotest;DataSource=WILLY;Port=3053;Dialect=3;Charset=UTF8;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0 |
| 271 | +``` |
| 272 | + |
| 273 | +If you changed user/password for connections then don't forget to update it in connection string. |
| 274 | + |
| 275 | + |
0 commit comments