Return meaningful error for meaningless Dockerfiles

More robust solution for #3293 than #3294 is.