# Secret-store to access Docker Secrets
[[secretstores.docker]]
## Unique identifier for the secretstore.
## This id can later be used in plugins to reference the secrets
## in this secret-store via @{<id>:<secret_key>} (mandatory)
id = "docker_secretstore"
there is a newline in the container’s secret, while there is none with the environment-variable setup.
Telegraf can only read the secret-file and use as-is! We should not mess with the content of the secret and we don’t. So if there is a newline at the end of the secret-file you will get a Telegraf secret with a newline at the end!
If your ./.secrets/telegraf_influxdb_token file does not contain a trailing newline, this clearly is an issue with docker or your configuration and should be fixed there.
Did you, by chance, echo the token into the file on your host? If so, did you use -n?
@srebhan not sure if I understand you correctly. Do you mean the token generation in general?
I generated the token at influx, copy it to clipboard, open vim and paste it, for both the token file ~/home-automation/.secrets/telegraf_influxdb_token and the environment variable in ~/home-automation/.env
" POSIX defines a line as a possibly empty sequence of non-newline characters, terminating in a newline, also called EOL (End-Of-Line), ASCII code 0x0A. Meanwhile, a text file is defined as consisting of lines.
Thus, the last line of a file, by definition and standard, should conclude that file with EOL."
I also checked the POSIX standard by myself now. It’s correct, a POSIX conform file must be terminated with a newline.
Sure, I can now tweak my file to be none POSIX conform, but I would be much better to change the telegraf code.
@srebhan All good questions and I don’t have a finale answer on that. Let’s do the following (suggestion): we enhance the documentation on GitHub and on the webpage and clearly state that telegraf handle/interprate all docker secrets as a binary file even if the file on the host was txt file. So the user should take care that file should not contain a \n at the end.
BTW: why we don’t have an issue w/ influx itself? All tokens work fine. All my tokens have a \n. What is the difference?
Where? For example, in a .env file, variables are key-value pairs; = and the line terminating character are used as delimiters for the value. The token doesn’t contain a new-line character.
@alexander-zimmermann and @Jason_Stirnaman even though, this is not a Telegraf specific issue I would appreciate a PR enhancing the documentation to make people aware of this behavior!