Skip to content

Commit 0d43120

Browse files
committed
in the docker pull, check ensure each step runs in verify.sh
1 parent b4009ba commit 0d43120

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

verify.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,23 @@ docker run -d -p 5000:5000 --name registry \
7878
-e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" \
7979
registry:2
8080

81-
# Step 2: Tag and push an image to the local registry with authentication
82-
echo "Tagging and pushing an image to the local registry with authentication..."
83-
echo "password" | docker login localhost:5000 -u user --password-stdin
84-
docker tag alpine:latest localhost:5000/alpine
85-
docker push localhost:5000/alpine
81+
# Step 2: Ensure the alpine:latest image is pulled before tagging and pushing
82+
if ! docker pull alpine:latest; then
83+
echo "Error: Failed to pull alpine:latest image." >&2
84+
exit 1
85+
fi
86+
87+
# Tag and push the image to the local registry with error handling
88+
echo "Tagging and pushing the alpine:latest image to the local registry..."
89+
if ! docker tag alpine:latest localhost:5000/alpine; then
90+
echo "Error: Failed to tag the alpine:latest image." >&2
91+
exit 1
92+
fi
93+
94+
if ! docker push localhost:5000/alpine; then
95+
echo "Error: Failed to push the alpine:latest image to the local registry." >&2
96+
exit 1
97+
fi
8698

8799
# Step 3: Verify the image in the local registry
88100
echo "Verifying the image in the local registry..."

0 commit comments

Comments
 (0)