-
Notifications
You must be signed in to change notification settings - Fork 2
Docker Quick Guide
Docker containers are an isolated standard unit of software that can run code or an application with all its dependencies included, somewhat similar to virtual machines, but take up much less space and share the host OS's kernel with each other.
EnergyMashupLab applications can be setup as individual docker containers with the ability to communicate with one another, and this guide will give you a quick explanation on how to set it up.
Check the Docker Docs to see if your host OS is compatible with Docker Engine, and install according to the specified instructions. For the examples in this guide we will use Debian/Ubuntu 20.04 LTS.
In your terminal, change directory to the specified app you want to build (LMA, TEUA, LME, etc) and use Maven to build the app into a compiled .jar file.
Take your compiled .jar and any necessary config files and move them into a new folder directory. This will be where you will include a Dockerfile which will help with building the Docker image. A Docker image behaves somewhat like a snapshot for a virtual machine, and is comprised of files and dependencies that can be run in a container.
Now, in the directory create a new file called "Dockerfile" and set it up like this:
WORKDIR [put docker image directory path here]
ADD [.jar file name in directory] [what you want the .jar to be named in the Docker image]
ADD [required conf file if necessary] [what you want the conf file to be named in the Docker image]
EXPOSE [port # your app uses]
CMD [write the command you want the Docker container to execute when it runs. Example: java -jar imagejar.jar imageconf.conf]
This creates a Docker image that includes the Java 8 environment along with the .jar file, and you can add other files if necessary. Be sure to include a blank newline like in the example. You can look here for further documentation on Dockerfiles if needed.
Go into your terminal and build an image from your Dockerfile with this command:
docker build --tag [name for your image] [image directory path]
You can check if the image built by listing images with the command:
docker image ls -a
Before you run any containers, you'll need to create a network if you plan for any locally running containers to communicate with each other. To create your network, type this command into the terminal:
docker network create --subnet [put subnet here. Recommended is 192.168.1.1/24] [network name]
This will create a bridge network with the specified subnet and name. You can get more information on Docker networks here.
NOTE: If you want your docker container to be discovered from outside your local docker network, you may need to specify published ports.
To run your image as a container, use this command:
docker run --net [name of network you want the container to run on] --ip [ip you want to set for the container] --name [name for container]
To see running containers, use the command docker container ls.
To stop a container from running, use the command docker container stop [container name]
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