Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

DockerIP

how to get IP of container from inside container: run this code in shell/bash: cat /etc/hosts | grep "$HOSTNAME" | awk -F" " '{print $1}'

explain:

  • "cat /etc/hosts" will show all host of current container, include IP of it self.
  • 'grep "$HOSTNAME"' will filter only row contain container ID from env of that session.
  • awk -F" " '{print $1}' : split code using white-space delimiter and print first element.

purpose:

  • usually when you need to config relative to IP of container e.g Apache Spark's config spark.driver.bindAddress to let master/cluster could access to driver's page under port 4040.

About

how to get IP of container when you run code

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages