操作
バグ #331
未完了Docker-3: ログ・詳細情報機能 (4h)
ステータス:
新規
優先度:
高め
担当者:
-
開始日:
2025-06-07
期日:
進捗率:
0%
予定工数:
説明
Dockerログ取得とコンテナ詳細情報機能を実装する。
実装内容¶
ログ取得機能¶
async getLogs(userId: string, host: string, container: string, lines: number = 100) {
const command = `docker logs --tail ${lines} ${container}`;
const result = await this.executeDockerCommand(host, command);
return {
content: [{
type: "text",
text: `Logs for ${container}:\n${result.stdout}\n${result.stderr}`
}]
};
}
async getComposeLog(userId: string, host: string, projectPath: string, service?: string) {
let command = `cd "${projectPath}" && docker-compose logs --tail 100`;
if (service) {
command += ` ${service}`;
}
const result = await this.executeDockerCommand(host, command);
return {
content: [{
type: "text",
text: result.stdout
}]
};
}
コンテナ詳細情報¶
async inspect(userId: string, host: string, container: string) {
const command = `docker inspect ${container}`;
const result = await this.executeDockerCommand(host, command);
if (result.code !== 0) {
throw new Error(`Failed to inspect container: ${result.stderr}`);
}
const inspectData = JSON.parse(result.stdout);
return {
content: [{
type: "text",
text: this.formatInspectData(inspectData[0])
}]
};
}
成果物¶
- ログ取得機能
- コンテナ詳細情報取得
- データ整形・表示機能
作業時間: 4時間¶
依存: Docker-2完了¶
表示するデータがありません
操作