Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Docker Setup

Alexander Dubrawski edited this page Aug 27, 2020 · 37 revisions

Install Docker

Ubuntu

Please refer to https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04

On Ubuntu you also need to install docker compose separately: apt install docker-compose

Mac

Please refer to https://docs.docker.com/docker-for-mac/install/

Windows

Please refer to https://docs.docker.com/docker-for-windows/install/

Get the Cockpit Source Code

  1. Clone the repository: git clone https://github.com/hyrise/Cockpit.git
  2. Enter the Cockpit directory: cd Cockpit

Basic Usage

To get a better understanding of how docker is working I recommend the following training: https://training.play-with-docker.com/dev-stage1/

Inside the docker setup we have five Images:

  • backend
  • frontend
  • influxdb
  • hyrise_1
  • hyrise_2

The Hyrise images are based on the same base image.

Running Setup on the local machine

If you are running the cockpit and your browser all on the local machine you can run:

docker-compose up

to build and start all images. If you just want to run the cockpit components in docker you can use:

docker-compose up backend frontend influxdb

If you want to run the containers in the background use the -d flag:

docker-compose up -d

The frontend will be reachable via. 127.0.0.1:5000. The backend via. 127.0.0.1:8000.

Running Setup on server or VM

If you run the setup on a remote server or VM you need to build the frontend explicitly. The reason is that you need to set the address off the machine in build time. So if your server has the address 123.123.123.123 you need to set the VUE_APP_BACKEND_HOST environment variable by running:

docker-compose build --no-cache --build-arg VUE_APP_BACKEND_HOST=123.123.123.123 frontend

After that you can run:

docker-compose up

to start the components

The frontend will be reachable over 123.123.123.123:5000. The backend via. 123.123.123.123:8000.

Shutting down Setup

To stop and remove the running containers execute the command:

docker-compose down

To stop and remove a specific container, for example, the frontend run:

docker-compose down frontend

Build the Hyrise image

If you use docker-compose up, docker will look if a Hyrise image exists. If not it will pull it from docker hub. This image is optimized to run on most architectures. If you want to use an optimized Hyrise for your architecture you can build the image manually. For that run:

docker image build --no-cache --tag hyrise/bp1920:hyrise ./hyrise

After that you can run:

docker-compose up

to start the components.

This way the Hyrise will be build for the native architecture of your machine. If you want to build the Hyrise optimized for a different architecture you can set the environment variable ARCHITECTURE in the Hyrise dockerfile (hyrise/Dockerfile). For example you could replace ENV ARCHITECTURE native to ENV ARCHITECTURE core2. There are many other options you can use. For that please have a look at https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html. The build process will automatically generate the needed Tables (for TPCC, TPCH,...) inside the image. So you don't need to worry about it. Please be aware that if you chose a newer architecture than the one of your system, there is a chance that the Hyrise will not work.

Add a Hyrise instance in the frontend

If the Hyrise instance is not running in docker you can add it in the frontend UI the normal way (click on "database", click on "add database", enter host and port). For example, your Hyrise instance is running at the server with the IP 123.123.123.123 on port 1234 you can enter: host: 123.123.123.123 port: 1234

Please remember: if you are using a not dockerized Hyrise you need to have the cached tables and plugins in the right location /usr/local/hyrise (on the machine where the Hyrise instance is running). On how to create the tables and plugins have a look at https://github.com/hyrise/Cockpit/wiki/Hyrise-Things

If you use the Hyrise instance in the docker containers, you can add them in the fronted UI (click on "database", click on "add database", enter host and port) with:

host: hyrise_1 port: 5432

and

host: hyrise_2 port: 5432

You need to use the container names, because docker containers can just communicate over their names.

Run Hyrise container on different machine

Say you want to run the cockpit (frontend, backend, influx) on machine A with the IP 123.123.123.123 and the Hyrise instances on machine B with the IP 444.444.444.444. Then you need to run the following command on machine A:

docker-compose build --no-cache --build-arg VUE_APP_BACKEND_HOST=123.123.123.123 frontend && docker-compose up frontend, backend, influx

On machine B you need to run:

docker-compose up hyrise_1 hyrise_2

You can add the Hyrise instances in the frontend UI (click on "database", click on "add database", enter host and port) with:

(hyrise_1)
host: 444.444.444.444 port: 5432

and

(hyrise_2)
host: 444.444.444.444 port: 6432

Access Hyrise via psql

If the Hyrise containers are running on your local machine run the following command to access hyrise_1:

psql -h 0.0.0.0 -p 5432

and

psql -h 0.0.0.0 -p 6432

to access hyrise_2.

If the Hyrise containers are running on a different machine for example with the IP 123.123.123.123 run:

(To access hyrise_1)
psql -h 123.123.123.123 -p 5432

(To access hyrise_2)
psql -h 123.123.123.123 -p 6432

Push hyrise image to Docker HUB

If you have access to the hyrise Docker HUB you can update the hyrise image and push it to it. For that please set the architecture environment variable in the docker file (hyrise/Dockerfile) to ENV ARCHITECTURE core2. Then you can build the new hyrise image by running:

docker image build --no-cache --tag hyrise/bp1920:hyrise ./hyrise

After that you can push it to docker hub:

docker image push hyrise/bp1920:hyrise

Quick fixes

  • If docker throws an error with the Hyrise containers, try to build it manually with: docker image build --no-cache --tag hyrise/bp1920:hyrise ./hyrise
  • If you have problems building the Hyrise image try to reduce the threads for make: for example, if the default four threads are too many and you want to change it to two adjust ENV ENV THREADS 4 in the docker file (in hyrise/Dockerfile) to ENV THREADS 2.
  • If you defined your own .env it could result in a failure of the docker set up (because the container will read the environment variables of a .env first). A quick fix is to simply create a new directory and clone the cockpit inside. Then do not create your own .env.
Clone this wiki locally