3.2 KiB
Our sample application
-
Visit the GitHub repository with all the materials of this workshop:
https://github.com/jpetazzo/container.training -
The application is in the dockercoins subdirectory
-
Let's look at the general layout of the source code:
there is a Compose file docker-compose.yml ...
... and 4 other services, each in its own directory:
rng= web service generating random byteshasher= web service computing hash of POSTed dataworker= background process usingrngandhasherwebui= web interface to watch progress
What's this application?
--
- It is a DockerCoin miner! .emoji[💰🐳📦🚢]
--
- No, you can't buy coffee with DockerCoins
--
-
How DockerCoins works:
-
workerasks torngto generate a few random bytes -
workerfeeds these bytes intohasher -
and repeat forever!
-
every second,
workerupdatesredisto indicate how many loops were done -
webuiqueriesredis, and computes and exposes "hashing speed" in your browser
-
Getting the application source code
-
We will clone the GitHub repository
-
The repository also contains scripts and tools that we will use through the workshop
.exercise[
- Clone the repository on
node1:git clone https://github.com/jpetazzo/container.training/
]
(You can also fork the repository on GitHub and clone your fork if you prefer that.)
Running the application
Without further ado, let's start our application.
.exercise[
-
Go to the
dockercoinsdirectory, in the cloned repo:cd ~/container.training/dockercoins -
Use Compose to build and run all containers:
docker-compose up
]
Compose tells Docker to build all container images (pulling the corresponding base images), then starts all containers, and displays aggregated logs.
Lots of logs
-
The application continuously generates logs
-
We can see the
workerservice making requests torngandhasher -
Let's put that in the background
.exercise[
- Stop the application by hitting
^C
]
-
^Cstops all containers by sending them theTERMsignal -
Some containers exit immediately, others take longer
(because they don't handleSIGTERMand end up being killed after a 10s timeout)
Connecting to the web UI
- The
webuicontainer exposes a web dashboard; let's view it
.exercise[
-
With a web browser, connect to
node1on port 8000 -
Remember: the
nodeXaliases are valid only on the nodes themselves -
In your browser, you need to enter the IP address of your node
]
A drawing area should show up, and after a few seconds, a blue graph will appear.
Clean up
- Before moving on, let's remove those containers
.exercise[
- Tell Compose to remove everything:
docker-compose down
]