Thursday, February 9, 2017

Rails 5 web console and Docker dev env.

If you use Rails 5 along docker for your development environment you may have seen something like this within your logs :


Cannot render console from 172.17.0.x! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255

To allow your current docker network to access the web console you should add some discovery logic within your config/environments/development.rb file.
 
require 'socket'
require 'ipaddr'

config.web_console.whitelisted_ips = Socket.ip_address_list.reduce([]) do |res, addrinfo|
  addrinfo.ipv4? ? res << IPAddr.new(addrinfo.ip_address).mask(24) : res
end

No comments:

Post a Comment