GridGain Developers Hub

Docker

This page describes how to run Control Center with Docker.

GridGain provides two docker images: Control Center Frontend and Control Center Backend. The easiest way to start Control Center in Docker is to use docker-compose, which enables you to start multi-container applications with a single configuration file.

Prerequisites

Compose File

Docker Compose needs a configuration files that defines an application. In our case, the application consists of two containers: Control Center Backend and Control Center Frontend. The frontend uses nginx to redirect user requests and, therefore, needs an nginx configuration file.

The example docker-compose file provided below defines the following actions:

  • Pull docker images for Control Center Frontend and Control Center Backend.

  • Mount nginx configuration file control-center.conf, which is used by the frontend to handle user requests (see below for a sample nginx configuration file).

  • Set configuration properties via environment variables. In the example below, they are commented out. See Configuration Parameters for instructions on how to change configuration parameters.

  • Start the backend and frontend containers and bind the frontend on port 8443.

docker-compose.yaml
version: '3'
services:
  backend:
    image: gridgain/control-center-backend:2021.06.00
    container_name: control-center-backend
    # Restart on crash.
    restart: on-failure
    environment:
      # Java settings
      - JVM_OPTS=

  frontend:
    image: gridgain/control-center-frontend:2021.06.00
    container_name: control-center-frontend
    depends_on:
      - backend
    volumes:
      - ${PWD}/control-center.conf:/etc/nginx/control-center.conf
    ports:
      # Proxy HTTP Nginx port (HOST_PORT:DOCKER_PORT)
      - 8008:8008

The following file is an example of the nginx configuration file.

control-center.conf
upstream backend-endpoint {
  server control-center-backend:3000;
}

server {
  listen 8008;
  server_name _;

  set $ignite_console_dir /data/www;

  root $ignite_console_dir;

  error_page 500 502 503 504 /50x.html;

  location / {
    try_files $uri /index.html = 404;
  }

  location /api/v1 {
    proxy_pass http://backend-endpoint;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass_header X-XSRF-TOKEN;
  }

  location /agents {
    proxy_pass http://backend-endpoint;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Origin http://backend-endpoint;
  }

  location /browsers {
    proxy_pass http://backend-endpoint;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Origin http://backend-endpoint;
    proxy_pass_header X-XSRF-TOKEN;
  }

  location = /50x.html {
    root $ignite_console_dir/error_page;
  }
}

Launching Control Center

Put docker-compose.yaml and control-center.conf into a directory and run the following command in that directory:

docker-compose up -d

The command starts two containers and binds the frontend container to port 8443. Run the following command to verify that the containers launched successfully:

$ docker-compose ps
         Name                        Command               State                    Ports
-----------------------------------------------------------------------------------------------------------
control-center-backend    /bin/sh -c ./control-center.sh   Up      3000/tcp
control-center-frontend   nginx -g daemon off;             Up      80/tcp, 8008/tcp, 0.0.0.0:8443->8443/tcp

In the above example, Control Center is running on port 8443. To access Control Center UI, open http://localhost:8443 in your browser. Change “localhost” to the actual hostname if you are running Control Center on a remote machine.

The Control Center port is also used to establish connection with the clusters. The cluster will try to connect to the default Control Center URI (http://localhost:3000). To change the Control Center port, use the management script:

{GRIDGAIN_HOME}/bin/management.sh --uri http://localhost:8443

See Control Center URI for details.

Configuration Parameters

You can set Control Center configuration parameters by providing environment variables in the docker-compose.yaml file.

For a complete list of parameters, see Configuration Parameters.