-
-
Save pantasio/2931157dfc47a7b381569473dcff7278 to your computer and use it in GitHub Desktop.
Get docker container ip
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
#!/usr/bin/env bash | |
#inside docker container | |
HOST_IP=$(/sbin/ip route|awk '/default/ { print $3 }') | |
CONTAINER_IP=$(curl "$HOST_IP:8000" 2>/dev/null) | |
echo "container ip is $CONTAINER_IP" |
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
#!/usr/bin/env bash | |
#then run something like this inside ./host | |
php -S 0.0.0.0:8000 |
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
#!/bin/env php | |
# ./host/index.php on host | |
echo $_SERVER['REMOTE_ADDR']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment