Skip to content
Menu
Poppy Ramblings Poppy Ramblings
  • About
Poppy Ramblings Poppy Ramblings

Getting IP address on very limited Docker containers

Posted on 2023-08-062025-01-13 by herbcso

Often Docker containers will have an extremely bare-bones Linux environment. In these scenarios, the ip and ifconfig commands are often not available. However I’d still like to be able to check what the Docker container’s IP address got assigned as. What do?

Well, one thing you can try is running hostname which should still be installed in even the most bare-bones configs, at least AFAIK. Then you can ping that hostname from another machine and see if it resolves. That can fail in a variety of ways though.

The other option here is to use the information available in /proc/net/fib_trie that will be available everywhere, since the kernel manages that. All credit here goes to this Medium article since I had never even seen this data before, nor knew of its existence.

They even provide these nice commands to run to parse the data in this “file”:

#!/usr/bin/env bash

## Get the primary and secundary IPs
awk '/\|--/ && !/\.0$|\.255$/ {print $2}' /proc/net/fib_trie

## Get only the primary IPs
awk '/32 host/ { print i } {i=$2}' /proc/net/fib_trie

Of course if awk is also not available, you can simply cat /proc/net/fib_trie and use the old eyeball-scanners to parse this data. ;]

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Shoutout for a nifty blog
  • Quick screenshots in Python
  • Getting IP address on very limited Docker containers
  • CIFS mount input/output error -5 with reading SOME directories
  • Avoid collisions in ~/bin

Recent Comments

  • herbcso on Debugging bash functions
  • herbcso on Everything you (n?)ever wanted to know about Unicode
  • herbcso on SpongeBob SquarePants in Buckaroo Banzai!?
  • mcshankins on SpongeBob SquarePants in Buckaroo Banzai!?
  • herbcso on PHP ZendDebugger and WAMP

Tags

ag AJAX bash blog cifs command-line cool debugging disk diun download firefox fix frameworks gdb homeassistant javascript packaging php plex portainer proxmox python ruby running samba search shoes silliness space SquarePants tcx therubyracer tips tricks tv unicode unix useful v8 WAMP weird windows xdebug zend

Archives

  • September 2024
  • January 2024
  • August 2023
  • September 2022
  • June 2022
  • March 2022
  • January 2022
  • May 2019
  • March 2019
  • April 2014
  • February 2014
  • October 2013
  • June 2013
  • April 2013
  • December 2012
  • November 2012
  • June 2012
  • April 2012
  • September 2011
  • October 2010
  • September 2010
  • August 2010
  • June 2010
  • May 2010
  • April 2010
  • October 2009
  • August 2008
  • June 2008
  • April 2008

Categories

  • android
  • browsers
  • coding
  • homelab
  • random nifty stuff
  • silly
  • site updates
  • Uncategorized

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
©2025 Poppy Ramblings | Powered by Superb Themes