def mem_limit_to_mb(mem_limit)
      unless mem_limit.downcase =~ /\A(\d+)([bkmg])\z/
        raise "Cannot parse docker memory limit: #{mem_limit}"
      end
      val = $1.to_i
      case $2
      when "b" then (val / (1024.0 * 1024.0)).ceil
      when "k" then (val / 1024.0).ceil
      when "m" then (val * 1.0).ceil
      when "g" then (val * 1024.0).ceil
      else raise "Can't convert #{mem_limit} to megabytes"
      end
    end
def mem_limit_to_mb(mem_limit)
      unless mem_limit.downcase =~ /\A(\d+)([bkmg])\z/
        raise "Cannot parse docker memory limit: #{mem_limit}"
      end
      val = $1.to_i
      case $2
      when "b" then (val / (1024.0 * 1024.0)).ceil
      when "k" then (val / 1024.0).ceil
      when "m" then (val * 1.0).ceil
      when "g" then (val * 1024.0).ceil
      else raise "Can't convert #{mem_limit} to megabytes"
      end
    end
Parse a Docker-style `mem_limit` and convert to megabytes.