Skip to content
This repository has been archived by the owner on Jul 6, 2018. It is now read-only.

IP Address of Docker Container? #59

Open
chrdunne opened this issue Jun 22, 2015 · 1 comment
Open

IP Address of Docker Container? #59

chrdunne opened this issue Jun 22, 2015 · 1 comment

Comments

@chrdunne
Copy link

Is it possible to get the IP address of the docker container for use in a recipe with code similar to this ec2 code?

ruby_block "print out public IP" do
block do
appservernode = search(:node, "name:#{appserver_instance_name}").first
Chef::Log.info("Application can be accessed at http://#{appservernode['ec2']['public_ipv4']}:3001")
end
end

@marc-
Copy link
Contributor

marc- commented Jul 3, 2015

Basically chef does converge docker containers same way as any other node. So, after running machine your chef server should contain node <machine_name>, and you'll be able to obtain its Ohai attributes:

ruby_block "print out public IP" do
  block do
    container = search(:node, "name:#{machine_name}").first
    Chef::Log.info("Application can be accessed at http://#{container['ipaddress']}:3001")
    Chef::Log.info("Application can be accessed at http://[#{container['ip6address']}]:3001")
  end
end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants