Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.17.0 docker containers not starting with default arguments #42038

Closed
wargamez opened this issue Dec 13, 2024 · 7 comments · Fixed by #42060
Closed

8.17.0 docker containers not starting with default arguments #42038

wargamez opened this issue Dec 13, 2024 · 7 comments · Fixed by #42060
Assignees
Labels
Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Comments

@wargamez
Copy link

docker run docker.elastic.co/beats/metricbeat:8.17.0
Error: unknown command "container" for "metricbeat"
Run 'metricbeat --help' for usage.

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Dec 13, 2024
@belimawr belimawr added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Dec 16, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Dec 16, 2024
@belimawr
Copy link
Contributor

belimawr commented Dec 16, 2024

I can confirm and reproduce it.

[Edit]
The most correct workaround is to pass --environment container to the docker image:

tiago@millennium-falcon ~ % docker run -d --name filebeat docker.elastic.co/beats/filebeat:8.17.0 --environment container 
8747f07c833089db7f5a0a5356ca0700bc9021fc20b659d695e2d8d8cadd8eaf
tiago@millennium-falcon ~ % docker logs -f filebeat 

This effectively fixes the bug (using -envrionment. One dash - instead of two --).

[Previous workaround]
I found an easy workaround, you can add -e as an argument and it will run and send the logs to stderr:

 docker run -d --name metribeat docker.elastic.co/beats/metricbeat:8.17.0 -e
 docker logs -f metribeat

@fonfalleh
Copy link

fonfalleh commented Dec 16, 2024

Probably the same cause and workaround possible as in #42039

@cmacknz cmacknz changed the title metricbeat 8.17.0 docker container not starting 8.17.0 docker containers not starting with default arguments Dec 16, 2024
@cmacknz cmacknz marked this as a duplicate of #42039 Dec 16, 2024
@cmacknz
Copy link
Member

cmacknz commented Dec 16, 2024

Yes, the Beats are mostly all built from the same Dockerfile template.

I closed #42039 as a duplicate and generalized the title of this issue so we don't end up with an issue for each unique Beat.

Thanks for reporting this. We have many automated tests for our Docker containers, but as it turns out none that start them without adding additional arguments.

The reference Kubernetes YAML includes the workaround by default.

containers:
- name: filebeat
image: docker.elastic.co/beats/filebeat-wolfi:9.0.0
args: [
"-c", "/etc/filebeat.yml",
"-e",
]

@wargamez
Copy link
Author

but adding a -e would redirect all logs to stderr and not stdout according to the documentation of -e, so really it is not a fix? A fix would be to change and fix the Dockerfile CMD commend to use --environment instead of -environment. filebeat --help says it should be with --environmen, but in the official Dockerfile and online doc -environment is used. Or fix the startup script to be able to handle -environment

Ref: https://hub.docker.com/layers/elastic/metricbeat/8.17.0/images/sha256-7ba3768050419565c3dc82ad5fa641fa7de1e5709dafbcd8aaf2c3399d589a24

docker run docker.elastic.co/beats/filebeat:8.17.0 --help
Usage:
filebeat [flags]
filebeat [command]

Available Commands:
export Export current config or index template
generate Generate Filebeat modules, filesets and fields.yml
help Help about any command
keystore Manage secrets keystore
modules Manage configured modules
run Run filebeat
setup Setup index template, dashboards and ML jobs
test Test config
version Show current version info

Flags:
-E, --E setting=value Configuration overwrite
-M, --M setting=value Module configuration overwrite
-N, --N Disable actual publishing for testing
-c, --c string Configuration file, relative to path.config (default "filebeat.yml")
--cpuprofile string Write cpu profile to file
-d, --d string Enable certain debug selectors
-e, --e Log to stderr and disable syslog/file output
--environment environmentVar set environment being ran in (default default)
-h, --help help for filebeat
--httpprof string Start pprof http server
--memprofile string Write memory profile to this file
--modules string List of enabled modules (comma separated)
--once Run filebeat only once until all harvesters reach EOF
--path.config string Configuration path
--path.data string Data path
--path.home string Home path
--path.logs string Logs path
--plugin pluginList Load additional plugins
--strict.perms Strict permission checking on config files (default true)
-v, --v Log at INFO level

Use "filebeat [command] --help" for more information about a command.

@fonfalleh
Copy link

fonfalleh commented Dec 16, 2024 via email

@cmacknz
Copy link
Member

cmacknz commented Dec 16, 2024

A fix would be to change and fix the Dockerfile CMD commend to use --environment instead of -environment.

Yes there is a draft PR for this in the works already #42060.

K8s has always used -e and I am over focusing on that because it is the most common use of the container, but you are right that -e is not the same as --environment and the known issue and even the docs for 8.17.0 for getting started can be updated to explicitly specifying --environment instead of -e as the work around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants