We can set up the required databases and tools using Docker. We support the usage of PostgreSQL, MySQL and SQL Server databases as docker instances. Moreover, there is a docker setup for Adminer, a web-based simple GUI that can connect all these databases.
- Docker must be installed
This repository provides the setup for two types of modes/profiles.
- simple : This mode setup a minimal database structure with only three tables in University database. The scripts for tables in this mode is available under the directory schema/simple.
- full : This mode setup a full database for University, which include minimum of 9 tables. The scripts for tables in this mode is available under the directory schema/full.
The docker configurations are available under the directory 1-setup/docker-setup
.
By default, the docker setup creates the simple mode which includes minimum number of tables. We can explicitly provide this mode in all the docker commands be prepending PROFILE=simple
to all docker commands. If no profile variable is set, this uses the simple mode automatically. For full mode, use the variable PROFILE=full
.
Depending on the required database, one can switch to the required directory and start the docker instance. For example, to run PostgreSQL, use the following commands:
cd postgresql
docker compose up
This starts the PostgreSQL database in the local docker with the necessary University
database and tables using the simple
mode. We can start the postgres in full
mode by using the command:
cd postgresql
PROFILE=full docker compose up
To use the Adminer GUI, we can run the docker-compose file inside the directory adminer-gui
:
cd adminer-gui
docker compose up
Once this is started, the database client is accessible on http://localhost:8080
Now you can connect to the database by providing the credentials which is available in the respective database docker-compose.yml
files.
NOTE: In Linux machine, use the url localhost
for the Server
field. However, in Mac and Windows, we should use host.docker.internal
as the value for host field.
It is also possible to run all three databases and also start the Adminer GUI tool. For it, use the docker-compose.yml
in the docker-setup
directory directly:
cd docker-setup
docker compose up
This starts the databases in simple
mode.
To use the full
profile, use:
cd docker-setup
PROFILE=full docker compose up
This starts PostgreSQL, MySQL, SQL Server and Adminer GUI in a single command.
Another way is to start all the databases manually using their on docker-compose.yml
files. If you have a preferred GUI such as DB Visualizer, PG Admin or any other, you can use it to connect to the docker databases. In such cases, they can be accessed using localhost
url with the correct port from respective docker-compose files.
Sometimes, when all the docker images are run together, there is a chance of some of them not starting. You may retry the same command 2-3 times to make it work. This is espcially the case with SQL Server.
If there is an issue, it is better to delete the installed docker images and rerun. For example, Microsoft recently changed the path for the tools in the docker and it caused issue. The path is updated now, but sometimes this might cause invalid combination of docker-compose file and the installed image.