-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
CONTAINER_NAME=nginx-d1c8ad79 | ||
|
||
test() { | ||
local retries=10 | ||
local nginx_container_ip | ||
nginx_container_ip=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER_NAME) | ||
|
||
echo "Nginx container IP: $nginx_container_ip" | ||
|
||
for ((attempt = 1; attempt <= retries; attempt++)); do | ||
echo "Attempt $attempt..." | ||
if curl --max-time 1 "http://$nginx_container_ip" >/dev/null; then | ||
echo "Successfully connected to nginx container." | ||
exit 0 | ||
else | ||
echo "Connection attempt $attempt failed." | ||
sleep 1 | ||
fi | ||
done | ||
|
||
echo "Failed to connect to nginx container." | ||
exit 1 | ||
} | ||
|
||
# Start nginx container in detached mode and name it 'nginx' | ||
docker run --detach --name $CONTAINER_NAME nginx:1.27 | ||
|
||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
CONTAINER_NAME=nginx-6c5e1575 | ||
|
||
test() { | ||
local retries=10 | ||
|
||
for ((attempt = 1; attempt <= retries; attempt++)); do | ||
echo "Attempt $attempt..." | ||
if curl --max-time 1 "http://127.0.0.1:8080" >/dev/null; then | ||
echo "Successfully connected to nginx container." | ||
exit 0 | ||
else | ||
echo "Connection attempt $attempt failed." | ||
sleep 1 | ||
fi | ||
done | ||
|
||
echo "Failed to connect to nginx container." | ||
exit 1 | ||
} | ||
|
||
# Start nginx container in detached mode and name it 'nginx' | ||
docker run --detach --publish 8080:80 --name $CONTAINER_NAME nginx:1.27 | ||
|
||
test |