Skip to content

Commit 3750cda

Browse files
authored
Merge pull request #3618 from Dokploy/feat/add-ui-to-show-unhealthy-status-logs
feat(logs): enhance container status display in logs
2 parents 3e64647 + 6cf448b commit 3750cda

4 files changed

Lines changed: 28 additions & 6 deletions

File tree

apps/dokploy/components/dashboard/application/logs/show.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const DockerLogs = dynamic(
3434
export const badgeStateColor = (state: string) => {
3535
switch (state) {
3636
case "running":
37+
case "ready":
3738
return "green";
3839
case "exited":
3940
case "shutdown":
@@ -142,6 +143,7 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => {
142143
<Badge variant={badgeStateColor(container.state)}>
143144
{container.state}
144145
</Badge>
146+
{container.status ? ` ${container.status}` : ""}
145147
</SelectItem>
146148
))}
147149
</div>
@@ -157,6 +159,9 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => {
157159
<Badge variant={badgeStateColor(container.state)}>
158160
{container.state}
159161
</Badge>
162+
{container.currentState
163+
? ` ${container.currentState}`
164+
: ""}
160165
</SelectItem>
161166
))}
162167
</>

apps/dokploy/components/dashboard/compose/logs/show-stack.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export const ShowDockerLogsStack = ({ appName, serverId }: Props) => {
128128
<Badge variant={badgeStateColor(container.state)}>
129129
{container.state}
130130
</Badge>
131+
{container.status ? ` ${container.status}` : ""}
131132
</SelectItem>
132133
))}
133134
</div>
@@ -143,6 +144,9 @@ export const ShowDockerLogsStack = ({ appName, serverId }: Props) => {
143144
<Badge variant={badgeStateColor(container.state)}>
144145
{container.state}
145146
</Badge>
147+
{container.currentState
148+
? ` ${container.currentState}`
149+
: ""}
146150
</SelectItem>
147151
))}
148152
</>

apps/dokploy/components/dashboard/compose/logs/show.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Loader2 } from "lucide-react";
2-
import dynamic from "next/dynamic";
3-
import { useEffect, useState } from "react";
42
import { badgeStateColor } from "@/components/dashboard/application/logs/show";
53
import { Badge } from "@/components/ui/badge";
4+
import dynamic from "next/dynamic";
5+
import { useEffect, useState } from "react";
66
import {
77
Card,
88
CardContent,
@@ -93,6 +93,7 @@ export const ShowDockerLogsCompose = ({
9393
<Badge variant={badgeStateColor(container.state)}>
9494
{container.state}
9595
</Badge>
96+
{container.status ? ` ${container.status}` : ""}
9697
</SelectItem>
9798
))}
9899
<SelectLabel>Containers ({data?.length})</SelectLabel>

packages/server/src/services/docker.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const getContainersByAppNameMatch = async (
109109
try {
110110
let result: string[] = [];
111111
const cmd =
112-
"docker ps -a --format 'CONTAINER ID : {{.ID}} | Name: {{.Names}} | State: {{.State}}'";
112+
"docker ps -a --format 'CONTAINER ID : {{.ID}} | Name: {{.Names}} | State: {{.State}} | Status: {{.Status}}'";
113113

114114
const command =
115115
appType === "docker-compose"
@@ -148,10 +148,14 @@ export const getContainersByAppNameMatch = async (
148148
const state = parts[2]
149149
? parts[2].replace("State: ", "").trim()
150150
: "No state";
151+
152+
const status = parts[3] ? parts[3].replace("Status: ", "").trim() : "";
153+
151154
return {
152155
containerId,
153156
name,
154157
state,
158+
status,
155159
};
156160
});
157161

@@ -168,7 +172,7 @@ export const getStackContainersByAppName = async (
168172
try {
169173
let result: string[] = [];
170174

171-
const command = `docker stack ps ${appName} --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}}'`;
175+
const command = `docker stack ps ${appName} --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}} | CurrentState: {{.CurrentState}}'`;
172176
if (serverId) {
173177
const { stdout, stderr } = await execAsyncRemote(serverId, command);
174178

@@ -205,11 +209,15 @@ export const getStackContainersByAppName = async (
205209
const node = parts[3]
206210
? parts[3].replace("Node: ", "").trim()
207211
: "No specific node";
212+
const currentState = parts[4]
213+
? parts[4].replace("CurrentState: ", "").trim()
214+
: "";
208215
return {
209216
containerId,
210217
name,
211218
state,
212219
node,
220+
currentState,
213221
};
214222
});
215223

@@ -226,8 +234,7 @@ export const getServiceContainersByAppName = async (
226234
try {
227235
let result: string[] = [];
228236

229-
const command = `docker service ps ${appName} --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}}'`;
230-
237+
const command = `docker service ps ${appName} --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}} | CurrentState: {{.CurrentState}}'`;
231238
if (serverId) {
232239
const { stdout, stderr } = await execAsyncRemote(serverId, command);
233240

@@ -265,10 +272,15 @@ export const getServiceContainersByAppName = async (
265272
const node = parts[3]
266273
? parts[3].replace("Node: ", "").trim()
267274
: "No specific node";
275+
276+
const currentState = parts[4]
277+
? parts[4].replace("CurrentState: ", "").trim()
278+
: "";
268279
return {
269280
containerId,
270281
name,
271282
state,
283+
currentState,
272284
node,
273285
};
274286
});

0 commit comments

Comments
 (0)