Open leolivier opened 3 years ago
I finally resolved to fix it by removing the 8 first chars this way:
this.stream = await this.container.logs({ follow: true, stdout: true }) as Stream;
this.stream.on('data', (info: any) => console.log(info.toString('utf-8').slice(8));
It's docker internal logging prefix (8 symbols).
Better to be described in README
It's docker internal logging prefix (8 symbols).
Better to be described in README
For those wondering, the documentation can be found here: https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerAttach (subsection: Stream format)
thank you @Skyclo Although it's not very hard to implement when you get this information, it's quite hard to get the info :) So maybe worth adding utility methods in the API to implement this and hide this complexity?
thank you @Skyclo Although it's not very hard to implement when you get this information, it's quite hard to get the info :) So maybe worth adding utility methods in the API to implement this and hide this complexity?
I think adding utility methods (maybe something like isStdout(<chunk>)
/isStderr(<chunk>)
) would be useful. However, I'm not 100% sure if they are within the scope of this library. The dockerode
package (similar scope) does not include any of these helper functions to my knowledge. As you said, its relatively easy when this information is made available.
Eventually I can make a pull request to this repo with some additional docs in the README or examples to show such functionality. I'm using this feature heavily, so I'd be willing to submit a PR.
Of course, that being said, the multiplexed stream is immediately removed in favor of raw data for TTY terminals. So far, from what I've seen, it still works with Tty: true
when creating a container, however, TTY functionality and/or stdin doesn't work. Maybe I'm not using it right... who knows... I'll figure it out eventually. 🤷♂️
Since this is your package @AgustinCB, any thoughts on adding these doc changes or helper functions?
Hello I'm trying the following code with an existing container (typescript):
But I get things like:
Translated to an UTF-8 string, this gives:
The log file contains lines like this: