Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get docker container ip
#!/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"
#!/usr/bin/env bash
#then run something like this inside ./host
php -S 0.0.0.0:8000
#!/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
You can’t perform that action at this time.