netdata / netdata

The open-source observability platform everyone needs!
https://www.netdata.cloud
GNU General Public License v3.0
69.38k stars 5.79k forks source link

[Feat]: Improve Docker image usability by adding WORKDIR /etc/netdata #17890

Open powerman opened 2 weeks ago

powerman commented 2 weeks ago

Problem

Most of commands executed inside a docker container are ./edit-config, which must be run in /etc/netdata. So, each time after docker exec we have to run cd /etc/netdata, which is a bit annoying.

Description

Make /etc/netdata default directory inside docker container.

Importance

nice to have

Value proposition

  1. Less commands to run each time we need to reconfigure netdata in a docker.
  2. Less errors because of forgotten cd.
  3. Better overall UX for docker deployments. :smile:

Proposed implementation

Add WORKDIR /etc/netdata near the bottom of the Dockerfile.

ilyam8 commented 2 weeks ago

Hey, @powerman. Please open one issue with all your suggestions.

powerman commented 2 weeks ago

Hey, @powerman. Please open one issue with all your suggestions.

Sorry, I don't get it. These suggestions are not related, they should be handled independently, some may be accepted while other rejected… so what's the point in mixing them all in a single issue? Every other project insist on making separate issues/PRs for everything which can be separated…

If you want to have one my issue max then just reopen any one from just closed ones, no matter which one.

ilyam8 commented 2 weeks ago

~All of them are about "Install Netdata with Docker" documentation. You can open one issue and list all your suggestions. Thanks!~

ilyam8 commented 2 weeks ago

I'm sorry, I meant #17892, #17891, and #17893. Not this one.

@Ferroin what do you think about this request?

Ferroin commented 2 weeks ago

The question comes down to whether the entrypoint script and the agent itself actually correctly handle being run in /etc/netdata instead of /. That said, if docker exec /etc/netdata/edit-config does not work but opening a shell, changing directory, and running edit-config does, that’s a bug in the edit-config script.

powerman commented 2 weeks ago

Hmm. To me it's a different thing. docker exec /etc/netdata/edit-config works okay. But with WORKDIR set docker exec ./edit-config will work.

ilyam8 commented 2 weeks ago

Should we just ln -s /etc/netdata/edit-config /usr/bin/? Will it do?

powerman commented 2 weeks ago

Good idea! But it won't make WORKDIR change useless - when in a container if you're in /etc/netdata then you can use shell auto-complete for existing config files. So, to me both adding symlink into /usr/bin (or, better, /usr/local/sbin) and WORKDIR /etc/netdata will provide best UX.

powerman commented 2 weeks ago

FWIW Here is one-liner example to debug plugins in docker:

sudo -u netdata -EH env -C /usr/libexec/netdata/plugins.d ./go.d.plugin -d -m nvidia_smi

Maybe worth to add it somewhere in the docs too.