hide protected containers from docker ps output

This commit is contained in:
justin committed 2026-09-25 18:24:40 -07:00
1 parent 22298e91d2
commit 5ff8bbbc9b
1 file changed
+9 -2
+9 -2
View File
@@ -2033,7 +2033,12 @@ async function handleWiki(message, query) {
} }
} }
function shQuote(str) {
return "'" + String(str).replace(/'/g, "'\\''") + "'";
}
async function runDockerCommand(args) { async function runDockerCommand(args) {
const remoteCommand = "docker " + args.map(shQuote).join(" ");
const { stdout } = await execFileAsync( const { stdout } = await execFileAsync(
"ssh", "ssh",
[ [
@@ -2041,7 +2046,7 @@ async function runDockerCommand(args) {
"-o", "StrictHostKeyChecking=no", "-o", "StrictHostKeyChecking=no",
"-o", "ConnectTimeout=10", "-o", "ConnectTimeout=10",
DOCKER_SSH_USER + "@" + DOCKER_SSH_HOST, DOCKER_SSH_USER + "@" + DOCKER_SSH_HOST,
"docker", ...args remoteCommand
], ],
{ timeout: DOCKER_SSH_TIMEOUT_MS } { timeout: DOCKER_SSH_TIMEOUT_MS }
); );
@@ -2066,7 +2071,9 @@ function isProtectedContainer(name) {
async function handleDockerPs(message) { async function handleDockerPs(message) {
try { try {
const containers = await fetchDockerContainers(); const containers = await fetchDockerContainers().then((list) =>
list.filter((c) => !isProtectedContainer(c.name))
);
if (containers.length === 0) { if (containers.length === 0) {
await message.reply("No containers found."); await message.reply("No containers found.");
return; return;