-
Notifications
You must be signed in to change notification settings - Fork 2
Docker Setup Part 2: Create Docker Containers
Run each executable JAR file built in Part 1
- Parity System
- Parity Client
- MySQL
- LMA (Local Market Agent and Local Market Manager)
- TEUA (Transactive Energy User Agent)
- Create Dockerfile for each application
- Create required config files
- Build docker images
- Run Docker images
In one directory, store these files: Parity System JAR, config file for Parity System, and the Dockerfile for System.
- Example: This directory, which uses the sample configuration file "system0620.conf".
Parity System Config File
market-data {
session = parity
multicast-interface = 192.168.1.50
multicast-group = 224.0.0.1
multicast-port = 5000
request-address = 192.168.1.50
request-port = 5001
}
market-report {
session = parity
multicast-interface = 192.168.1.50
multicast-group = 224.0.0.1
multicast-port = 6000
request-address = 192.168.1.50
request-port = 6001
}
order-entry {
address = 192.168.1.50
port = 4000
}
...
Parity System Docker File
FROM java:8
WORKDIR <PATH TO JAR & CONF FILE>
ADD parity-system.jar parity-system.jar
ADD system0620.conf system0620.conf
EXPOSE 4000
CMD java -jar parity-system.jar system0620.confIn one directory, store these files: Parity Client JAR, config file for Parity Client, and the Dockerfile for Client.
- Example: This directory, which uses the sample configuration file "client0620.conf".
Parity Client Config File
order-entry {
address = 192.168.1.50
port = 4000
username = parity
password = parity
}
...
Parity Client Docker File
FROM java:8
WORKDIR <PATH TO JAR & CONF FILE>
ADD parity-client.jar parity-client.jar
ADD client0620.conf client0620.conf
EXPOSE 39401
EXPOSE 39402
CMD java -jar parity-client.jar 192.168.1.54 client0620.confIn one directory, store these files: SQL file to create the database, and the Dockerfile for MySQL
SQL file
CREATE DATABASE IF NOT EXISTS nist_cts_eml;
USE nist_cts_eml;
DROP TABLE IF EXISTS `hibernate_sequence`;
CREATE TABLE `hibernate_sequence` (
`next_val` bigint DEFAULT NULL
);
DROP TABLE IF EXISTS `position`;
CREATE TABLE `position` (
`counter_id` bigint NOT NULL,
`end_time` datetime NOT NULL,
`position_party` bigint DEFAULT NULL,
`quantity` bigint DEFAULT NULL,
`start_time` datetime NOT NULL,
`transaction_id` bigint DEFAULT NULL,
PRIMARY KEY (`counter_id`)
);
LOCK TABLES `hibernate_sequence` WRITE;
INSERT INTO `hibernate_sequence` VALUES (1);
UNLOCK TABLES;
MySQL Dockerfile
FROM mysql:latest
ENV MYSQL_ROOT_PASSWORD capstone@123
ENV MYSQL_DATABASE nist_cts_eml
ENV MYSQL_USER eml
ENV MYSQL_PASSWORD capstone@123
ADD <SQL file name>.sql /docker-entrypoint-initdb.d/<SQL file name>.sql
RUN chmod -R 775 /docker-entrypoint-initdb.d
In one directory, keep all these files: LMA jar & DockerFile for LMA
LMA Dockerfile
FROM java:8
WORKDIR <PATH TO JAR FILE>
ADD lmma.jar lmma.jar
EXPOSE 8080
EXPOSE 39401
EXPOSE 39402
CMD java -jar lmma.jarIn one directory, keep all these files: TEUA jar & DockerFile for TEUA
TEUA Dockerfile
FROM java:8
WORKDIR <PATH TO JAR FILE>
ADD teua.jar teua.jar
EXPOSE 8080
CMD java -jar teua.jar- Create docker images
Parity System:
- For Windows -
docker build -t system:1.0 <PATH TO SYSTEM DOCKER FILE> - For Mac -
docker build --tag system:1.0 <PATH TO SYSTEM DOCKER FILE>
Parity Client:
- For Windows -
docker build -t client:1.0 <PATH TO CLIENT DOCKER FILE> - For Mac -
docker build --tag client:1.0 <PATH TO CLIENT DOCKER FILE>
LMA:
- For Windows -
docker build -t lma:1.0 <PATH TO LMA DOCKER FILE> - For Mac -
docker build --tag lma:1.0 <PATH TO LMA DOCKER FILE>
TEUA:
- For Windows -
docker build -t teua:1.0 <PATH TO TEUA DOCKER FILE> - For Mac -
docker build --tag teua:1.0 <PATH TO TEUA DOCKER FILE>
-
Create a docker network to run the container in with this command:
docker network create --subnet=192.168.1.1/24 ctsnet -
Run the newly created System Docker image inside a container using the specified IP with this command:
docker run --net ctsnet --ip 192.168.1.50 --name systemcontainer1 system:1.0 -
Run the newly created Client Docker image inside a container using the specified IP with this command:
docker run --net ctsnet --ip 192.168.1.51 -i -t --name clientcontainer1 client:1.0 -
Run MySQL:
-
Approach 1: using mysql image and set up
- Pull mysql docker image:
docker pull mysql - Run the newly created MySQL Docker image inside a container using the specified IP with this command:
docker run --net ctsnet --ip 192.168.1.53 --name mysqlctsnet -p 3306:3306 -e MYSQL_ROOT_PASSWORD=capstone@123 mysql - Open MySQL console in docker using this command:
docker exec -it mysqlctsnet bash - Enter credentials in MySQL console using this command:
mysql -u root -pcapstone@123 - Create/setup database and user using following command:
- To create database:
create database nist_cts_eml; - To create user:
create user eml@192.168.1.54 identified by ""; - To grant full access of database to user:
grant all on nist_cts_eml.* to eml@192.168.1.54; - To set password for user:
SET PASSWORD FOR 'eml'@'192.168.1.54' = 'capstone@123';
- To create database:
- Pull mysql docker image:
-
Approach 2: using docker file of MySQL:
- Build Docker image:
docker build --tag mysql:1.0 <PATH TO MYSQL DOCKER FILE> - Run MYSQL from docker image:
docker run --net ctsnet --ip 192.168.1.53 --rm --name eml-mysql -p 3306:3306 mysql:1.0 -
Note: In case of error (Bind: Address already in use), run
sudo service mysql stopthen run MYSQL from docker image again.
- Build Docker image:
-
-
Run the newly created LMA Docker image inside a container using the specified IP with this command:
docker run --net ctsnet --ip 192.168.1.54 --name lmmacontainer1 lma:1.0 -
Run the newly created TEUA Docker image inside a container using the specified IP with this command:
docker run --net ctsnet --ip 192.168.1.55 -p 8080:8080 --name teuacontainer1 teua:1.0
Code Documentation
- Actor Pseudocode - LMA, LMM, TEUA
- RESTful Controller Payloads
- Position Manager
- Logging
- Time in CTS
- UML and Java Classes
- Simple Binary Encoding (SBE)
- SBE Quick Guide
- Auction Market
Building and Running the Project
- Setup Run and Drive - with YouTube videos
- Dependencies and Prerequisites
- Set Up MySQL
- Parity Terminal Client
- Project Build Steps
- In Case of Difficulty
Docker
- Docker Background
- Docker Setup Requirements
- Docker Setup Part 1
- Docker Setup Part 2
- Running EML-CTS as a Single Executable JAR
- Docker Quick Guide
General Tech Guides
Spring 2024 Updates