[SUPPORT] Getting logs from a running container #678
Unanswered
sbodapati-de
asked this question in
Q&A
Replies: 2 comments
-
I have the same question: need to access logs from an already running container with already running execs.. any ideas on how to achieve this? |
Beta Was this translation helpful? Give feedback.
0 replies
-
this is how i access the logs: export async function getContainerLogs(id: string): Promise<string> {
const c = await docker.getContainer(id)
const data: Buffer = await c.logs({
"stdout": true,
"tail": "all",
"timestamps": true
})
return data.toString("utf-8")
} https://docs.docker.com/engine/api/v1.37/#tag/Container/operation/ContainerLogs guess you use follow = true ? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi , i have three rest APIs , one to create a container and return container id , second one to exec a command and the third one to stream logs when container id is passed ,
GET setup/:image_name
GET run/:container_id
GET logs/:container_id
for the third API i am using docker.getContainer -> container.logs -> container.modem.demuxStream and am passing a writeable nodejs stream at stdout and stderr for sending back the logs.
I'm somehow not able to access the logs , but , if the writeable stream is passed during exec to container.modem.demuxStream , everything works fine.
How can i access logs after exec from a running container, given the container id?
Beta Was this translation helpful? Give feedback.
All reactions