class Kitchen::Driver::Dokken

def build_work_image(state)

def build_work_image(state)
  info('Building work image..')
  return if ::Docker::Image.exist?(work_image, {}, docker_connection)
  begin
    @intermediate_image = ::Docker::Image.build(
      work_image_dockerfile,
      {
        't' => work_image,
      },
      docker_connection
    )
  # credit to https://github.com/someara/kitchen-dokken/issues/95#issue-224697526
  rescue Docker::Error::UnexpectedResponseError => e
    msg = 'work_image build failed: '
    msg += JSON.parse(e.to_s.split("\r\n").last)['error'].to_s
    msg += '. The common scenerios are incorrect intermediate'
    msg += 'instructions such as not including `-y` on an `apt-get` '
    msg += 'or similar. The other common scenerio is a transient '
    msg += 'error such as an unresponsive mirror.'
    raise msg
  # fallback rescue above should catch most of the errors
  rescue => e
    raise "work_image build failed: #{e}"
  end
  state[:work_image] = work_image
end