Skip to content

Cognitivity Testing Using Docker

Ophir Katz edited this page Jun 21, 2018 · 1 revision

This guide instructs developers on how to use docker when testing the database's capabilities locally.

It also appears as part of the source files, but given here in a more convenient way:

How to use the docker:

  • Install docker
  • Execute command: sudo docker build -t database . This command will build the image of the docker from the Dockerfile.
  • Execute command: sudo docker run -d --name database -p3306:3306 database This command will run the image, and will redirect port 3306 of the docker to port 3306 of the local host. You can add the flag -d (added) so the docker will run in background.
  • Execute command: sudo docker exec -it database bash Using this command you can open bash shell in the docker.
  • Execute command: chmod 777 construct_db.sh This command will allow executing to script that builds the database from the settings file.
  • Execute command: ./construct_db.sh This command will construct the database using the db_settings file. Note: Sometimes there is a need to wait a few seconds before this command would run correctly. If there's an error, wait and try again.

The docker is ready for use! At the end:

  • Execute command: docker stop database This command will stop the instance named database (you can resume it by docker start database).
  • Execute command: docker rm database This will erase it so it will be possible reuse the name again.

Connect to the mysql db directly from your computer by using the command:

  • mysql -h 0.0.0.0 -P 3306 -uroot -p"password" This should be done from inside the docker environment.
Clone this wiki locally