How to query a container host's IP address from inside a container

Solution Verified - Updated -

Issue

  • What is the method to get a host's IP address inside the container so that the app running in the container can transmit data to an agent running on the host? Is there a better way to get the host IP address other than running the following command inside the container?
        # netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}'

Environment

  • OpenShift Enterprise 3.1

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.