Skip to content

Commit 5b48e45

Browse files
authored
Merge pull request #3626 from Dokploy/3535-container-creation-fails-after-vps-restart-bind-source-path-does-not-exist
feat(logs): display error messages for containers in dashboard logs
2 parents 8ba26f0 + 3a7f76e commit 5b48e45

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ export const ShowDockerLogs = ({ appName, serverId }: Props) => {
171171
</SelectGroup>
172172
</SelectContent>
173173
</Select>
174+
{option === "swarm" &&
175+
services?.find((c) => c.containerId === containerId)?.error && (
176+
<div className="rounded-md bg-destructive/10 border border-destructive/20 px-3 py-2 text-sm text-destructive">
177+
<span className="font-medium">Error: </span>
178+
{services.find((c) => c.containerId === containerId)?.error}
179+
</div>
180+
)}
174181
<DockerLogs
175182
serverId={serverId || ""}
176183
containerId={containerId || "select-a-container"}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ export const ShowDockerLogsStack = ({ appName, serverId }: Props) => {
156156
</SelectGroup>
157157
</SelectContent>
158158
</Select>
159+
{option === "swarm" &&
160+
services?.find((c) => c.containerId === containerId)?.error && (
161+
<div className="rounded-md bg-destructive/10 border border-destructive/20 px-3 py-2 text-sm text-destructive">
162+
<span className="font-medium">Error: </span>
163+
{services.find((c) => c.containerId === containerId)?.error}
164+
</div>
165+
)}
159166
<DockerLogs
160167
serverId={serverId || ""}
161168
containerId={containerId || "select-a-container"}

packages/server/src/services/docker.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ export const getStackContainersByAppName = async (
172172
try {
173173
let result: string[] = [];
174174

175-
const command = `docker stack ps ${appName} --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}} | CurrentState: {{.CurrentState}}'`;
175+
const command = `docker stack ps ${appName} --no-trunc --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}} | CurrentState: {{.CurrentState}} | Error: {{.Error}}'`;
176+
177+
console.log("command ", command);
176178
if (serverId) {
177179
const { stdout, stderr } = await execAsyncRemote(serverId, command);
178180

@@ -212,12 +214,14 @@ export const getStackContainersByAppName = async (
212214
const currentState = parts[4]
213215
? parts[4].replace("CurrentState: ", "").trim()
214216
: "";
217+
const error = parts[5] ? parts[5].replace("Error: ", "").trim() : "";
215218
return {
216219
containerId,
217220
name,
218221
state,
219222
node,
220223
currentState,
224+
error,
221225
};
222226
});
223227

@@ -234,7 +238,7 @@ export const getServiceContainersByAppName = async (
234238
try {
235239
let result: string[] = [];
236240

237-
const command = `docker service ps ${appName} --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}} | CurrentState: {{.CurrentState}}'`;
241+
const command = `docker service ps ${appName} --no-trunc --format 'CONTAINER ID : {{.ID}} | Name: {{.Name}} | State: {{.DesiredState}} | Node: {{.Node}} | CurrentState: {{.CurrentState}} | Error: {{.Error}}'`;
238242
if (serverId) {
239243
const { stdout, stderr } = await execAsyncRemote(serverId, command);
240244

@@ -276,12 +280,14 @@ export const getServiceContainersByAppName = async (
276280
const currentState = parts[4]
277281
? parts[4].replace("CurrentState: ", "").trim()
278282
: "";
283+
const error = parts[5] ? parts[5].replace("Error: ", "").trim() : "";
279284
return {
280285
containerId,
281286
name,
282287
state,
283288
currentState,
284289
node,
290+
error,
285291
};
286292
});
287293

0 commit comments

Comments
 (0)