This is one of the “one minute MVS” series of topics to provide the core of what you need to know on a subject to get started.
The problem
I want to run a self contained application suites on my laptop. There are two versions, old and new. Both use the same IP ports, and configuration files (/etc/myapp/config.yaml). How do I do it?
One solution is to use docker.
Docker is container management.
You need to install docker on your machine. I used sudo apt install docker.
My first docker image
docker run --rm --name jaeger \
-p 16686:16686 \
-p 4317:4317 \
-p 4318:4318 \
-p 5778:5778 \
-p 9411:9411 \
cr.jaegertracing.io/jaegertracing/jaeger:2.19.0
When you run this command
- the first time, it downloads a prebuilt image cr.jaegertracing.io/jaegertracing/jaeger from a docker site. The second time is uses the previously downloaded image
- it will download version 2.19.0 (you can specify latest)
- it is given a name jaeger
- it also has a number which can be used in commands
- it maps its ports -p external:internal. In my config file I have endpoint: “0.0.0.0:4317”. This maps to the 4317 on my laptop. I could have a second container and pass parameters -p 5317: 4317. The same config file can be used. To talk to the second container, I need to use port 5317.
- when it shuts down, the image is removed (–rm)
- you stop the image using docker stop jaeger. You can restart it with docker start jaeger.
- you remove the image using docker rm jaeger.
Commands
See docker commands.
Using files within a docker image
The program may use a configuration file for example /etc/myprog/config. You can map this to a file outside of the container.
For example
docker run --rm --name otelcollector \
--volume "$(pwd)/o1.yaml":/otel-config.yaml \
-v "/mnt/Colin/ssl/ssl2/tempcert.pem":"/server.pem" \
-v "/mnt/Colin/ssl/ssl2/tempcert.key.pem":"/server.key.pem" \
...
otel/opentelemetry-collector --config otel-config.yaml
This says when the application accesses /server.key.pem, this is mapped to file /mnt/Colin/ssl/ssl2/tempcert.key.pem on my laptop.
In my config file I have
receivers:
otlp:
protocols:
grpc:
endpoint: "0.0.0.0:4317"
tls:
cert_file: server.pem
key_file: server.key.pem
min_version: "1.3" # Enforces TLS 1.3 as the minimum requirement
max_version: "1.3" # Locks maximum version to TLS 1.3
cipher_suites: []
reload_interval: "1h"
http:
Docker to Docker
I have one docker image with OpenTelemetry (otel), and another with Jaeger, which is used to display information produces by the otel image. I found this article useful
Create a docker network (once)
docker network create otel-jaeger-network
This can be used
docker run --rm --name jaeger \
...\
--network otel-jaeger-network \
jaegertracing/all-in-one:latest
and
docker run --rm --name otelcollector \
--volume "$(pwd)/o1.yaml":/otel-config.yaml \
...
--network otel-jaeger-network \
otel/opentelemetry-collector --config otel-config.yaml
The otel config file has
endpoint: "0.0.0.0:4317"
The jaeger has default of localhost:4317 because these share the same network they are each end of a socket.
Docker to docker
The problem
I have one application running in one docker container, and another application in another docker container. How do I get them to talk to each other?
Docker to Docker
I have one docker image with OpenTelemetry (Otel), and another with Jaeger, which is used to display information produces by the Otel image. I found this article useful. You do not need to know what Otel and Jaeger are, you just need to know that data from an external site is sent to Otel, and Otel passes some transformed data to Jaeger.
You need to create a docker network, then have the docker images use this network.
Create a docker network (once)
docker network create otel-jaeger-network
Use it
This can be used
docker run --rm --name jaeger \
...\
--network otel-jaeger-network \
jaegertracing/all-in-one:latest
and
docker run --rm --name otelcollector \
--volume "$(pwd)/o1.yaml":/otel-config.yaml \
...
--network otel-jaeger-network \
otel/opentelemetry-collector --config otel-config.yaml
Sending data from z/OS to Otel
A program running on z/OS sends data to my laptop and the data goes to the Otel container.
I’ve configured the Otel container
docker run ...
--publish 9999:4317
My z/OS code sends data to port 9999 on my laptop. The docker code maps port 9999 to port 4317 within the Otel container.
The Otel config file has
endpoint: "0.0.0.0:4317"
and so the Otel code can process the data sent from z/OS
In practice it would be easier to use port 4317 from z/OS and use
--publish 4317:4317
Sending data from Otel to Jaeger
My Otel configuration has
exporters:
otlphttp/jaeger:
endpoint: "http://jaeger2:4318"
tls:
insecure: true
The docker code extracts the value jaeger2 from the endpoint.
This ties up with the Jaeger container definition
docker run --rm --name jaeger2 ...
The program in the Jaeger container is listening on port 4318, and so the data is sent from the Otel container to the Jaeger container.