grafana / alloy

OpenTelemetry Collector distribution with programmable pipelines
https://grafana.com/oss/alloy
Apache License 2.0
1.27k stars 172 forks source link

Support `netcat` in `grafana/agent` docker image #327

Open eddumelendez opened 10 months ago

eddumelendez commented 10 months ago

Request

Testcontainers libraries check that the requested ports are open in the container executing the following piece of code. Currently, when trying to use the following definition

GenericContainer<?> grafanaAgent() {
    return new GenericContainer<>("grafana/agent:v0.37.2")
            .withExposedPorts(12345)
            .withCopyFileToContainer(
                    MountableFile.forClasspathResource("agent-config.river"),
                    "/etc/agent/agent-config.river"
            )
            .withEnv("AGENT_MODE", "flow")
            .withCommand("run", "--server.http.listen-addr=0.0.0.0:12345", "etc/agent/config.river");
}

the error below is displayed and the container doesn't start

check: Container.ExecResult(exitCode=137, stdout=, stderr=/bin/sh: 1: nc: not found
/bin/bash: connect: Cannot assign requested address
/bin/bash: line 1: /dev/tcp/localhost/12345: Cannot assign requested address
)

Use case

I'd like to use grafana/agent docker image with Testcontainers.

thampiotr commented 10 months ago

Seems like you should be able to use netcat by creating a new Docker image based on grafana/agent with netcat package installed. We want to keep our images lightweight and since Docker allows to easily extend them, it shouldn't prevent users from installing other programs when needed.

For the purpose of testing the containers, you may also want to consider checking for the open port from outside the container.

github-actions[bot] commented 9 months ago

This issue has not had any activity in the past 30 days, so the needs-attention label has been added to it. If the opened issue is a bug, check to see if a newer release fixed your issue. If it is no longer relevant, please feel free to close this issue. The needs-attention label signals to maintainers that something has fallen through the cracks. No action is needed by you; your issue will be kept open and you do not have to respond to this comment. The label will be removed the next time this job runs if there is new activity. Thank you for your contributions!