Skip to content

Commit 0a272c7

Browse files
committed
docker ps fixes
1 parent 204854a commit 0a272c7

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

addons/appapi.sh

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,17 @@ else
8686
then
8787
# Remove HaRP container
8888
docker_prune_this 'ghcr.io/nextcloud/nextcloud-appapi-harp'
89-
# Remove all ExApp containers
90-
DOCKERPS=$(docker ps -a --format '{{.Names}}' | grep '^nc_app_' || true)
91-
if [ -n "$DOCKERPS" ]
92-
then
93-
for container_name in $DOCKERPS
94-
do
95-
docker_prune_this "$container_name"
96-
done
97-
fi
89+
# Remove all ExApp containers and their images
90+
docker ps -a --format '{{.Names}}' | grep '^nc_app_' | while read -r container_name
91+
do
92+
docker_prune_this "$container_name"
93+
done
94+
95+
# Clean up ExApp images
96+
docker images --format '{{.Repository}}:{{.Tag}}' | grep '^ghcr.io/nextcloud/.*:' | while read -r image_name
97+
do
98+
docker rmi -f "$image_name" 2>/dev/null || true
99+
done
98100
fi
99101

100102
# Remove Apache proxy configuration for ExApps
@@ -295,7 +297,7 @@ Please check Docker logs:
295297
sleep 5
296298

297299
# Verify HaRP is running
298-
if ! docker ps | grep -q "$HARP_CONTAINER_NAME"
300+
if ! docker ps --format '{{.Names}}' | grep -q "^${HARP_CONTAINER_NAME}$"
299301
then
300302
msg_box "HaRP container failed to start.
301303
@@ -500,7 +502,7 @@ You can test it manually from the AppAPI Admin Settings page."
500502
CONTAINER_NAME="nc_app_${TEST_APP}"
501503
while [ $WAIT_COUNT -lt $MAX_WAIT ]
502504
do
503-
if docker ps | grep -q "$CONTAINER_NAME"
505+
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"
504506
then
505507
print_text_in_color "$IGreen" "✓ Container started!"
506508
break
@@ -515,7 +517,7 @@ You can test it manually from the AppAPI Admin Settings page."
515517
done
516518

517519
# Check if container is running
518-
if ! docker ps | grep -q "$CONTAINER_NAME"
520+
if ! docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"
519521
then
520522
msg_box "Note: Test ExApp container failed to start within 120 seconds.
521523
@@ -537,7 +539,7 @@ You can test it manually from the AppAPI Admin Settings page."
537539
print_text_in_color "$IGreen" "✓ Container is healthy!"
538540
else
539541
# Container might not have health check, check if running
540-
if docker ps | grep -q "$CONTAINER_NAME"
542+
if docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"
541543
then
542544
print_text_in_color "$IGreen" "✓ Container is running!"
543545
fi
@@ -585,7 +587,7 @@ You can test it manually from the AppAPI Admin Settings page."
585587
nextcloud_occ_no_check app_api:app:unregister "$TEST_APP" --rm-data 2>/dev/null || true
586588

587589
# Verify cleanup
588-
if docker ps -a | grep -q "$CONTAINER_NAME" 2>/dev/null
590+
if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"
589591
then
590592
print_text_in_color "$ICyan" "Removing test container..."
591593
docker rm -f "$CONTAINER_NAME" 2>/dev/null || true

0 commit comments

Comments
 (0)