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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content