Skip to content

Commit 516e8ec

Browse files
authored
Added info how to patch container images to run in background (#124)
* Added info how to patch container images to run in background * Adding more troubleshooting tips for container run problems
1 parent acdfb37 commit 516e8ec

File tree

2 files changed

+62
-4
lines changed

2 files changed

+62
-4
lines changed

content/en/docs/help/troubleshooting.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,64 @@ When you are getting an unexpected result when accessing localhost / \*.internal
2626
other service serves content on that port. Check your `docker ps -a`
2727
- Also check `lsof -i | grep PORTNUMBER` to look if something on your host OS is serving content on that port
2828

29+
## Container not running anymore / Keeping containers running for GMT to measure
30+
31+
GMT will start a container with `docker run` in the *BOOT* phase and then start the workload defined in the *flows*
32+
in the *RUNTIME* phase.
33+
34+
Sometimes containers do not have *daemon* processes that keeps them open and / or the workload starts directly on container
35+
boot.
36+
37+
You might then see a message like:
38+
39+
- **Container 'test-container' exited during runtime phase**
40+
- or
41+
- **Container 'test-container' exited during runtime phase**
42+
43+
In order to properly your container you must instrument it to *just* instantiate and not start anything than *daemons* or background processes.
44+
45+
The easiest way to do so is to overwrite the *CMD* or *ENTRYPOINT* attribute in your container via the `usage_scenario.yml`file.
46+
47+
Example:
48+
49+
```yml
50+
services:
51+
my-cool-service:
52+
image: static-binary-image
53+
entrypoint: tail -f /dev/null
54+
```
55+
56+
If you do not have the `tail` binary in your container alternatives are to open a shell (`sh`) or to make a `sleep 100000000`.
57+
58+
Sometimes however you only have a static binary in a *distroless container* and nothing else. In that case we recommend
59+
wrapping your container in a *busybox*, which is extremely low overhead.
60+
61+
Example for a *Dockerfile*:
62+
63+
```Dockerfile
64+
FROM your-org/your-static-image AS build # your container image
65+
66+
FROM busybox AS runtime
67+
COPY --from=build /bin/my-static-binary /bin/my-static-binary
68+
69+
ENTRYPOINT ["tail", "-f", "/dev/null"]
70+
```
71+
72+
GMT can then build the *Dockerfile* for you. Just supply the `build` command in your [usage_scenario.yml →]({{< relref "/docs/measuring/usage-scenario" >}}.
73+
74+
## Container already running on system
75+
76+
A typical error message for this is:
77+
78+
- **Container 'test-container' is already running on system. Please close it before running the tool.**
79+
80+
This indicates an unclean shutdown of the GMT.
81+
82+
Please close all containers you have running, restart GMT DB and Dashboard containers, and close all metric providers
83+
with `tools/kill_gmt.sh`.
84+
85+
See also *1.* on [Helper Tools →]({{< relref "helper-tools" >}}) for more info on this.
86+
2987
## ERR_NAME_NOT_RESOLVED / DNS_PROBE_POSSIBLE
3088

3189
- Hostname of container correct? `docker ps` tells you the container name, which is also the hostname

content/en/docs/measuring/containerizing-applications.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ When containerizing apps for the Green Metrics Tool,
1818
the containers *must not* shut down after starting them.
1919

2020
So you either must have a daemon / process running inside the container
21-
that keeps the container running or use the `command` option in the [usage_scenario.yml →]({{< relref "usage-scenario" >}})
22-
file to start a shell that keeps the container running.
21+
that keeps the container running or use the `command` or `entrypoint` option in the [usage_scenario.yml →]({{< relref "usage-scenario" >}})
22+
file to start a process that will keep the container running.
23+
See [Troubleshooting - Keeping containers running for GMT to measure →]({{< relref "troubleshooting" >}}) for an example.
2324

24-
This is because our tool sends the commands to the containers after they have
25-
all been orchestrated and does not support one-off container starts with parameters.
25+
This is because our tool sends the commands to the containers after they have all been orchestrated and must precisely time the moment when the container starts running a workload.
2626

2727
## Containerizing
2828

0 commit comments

Comments
 (0)