check if working dir is a directory and raise corresponding errors when making dir.

Docker-DCO-1.1-Signed-off-by: Liang-Chi Hsieh <viirya@gmail.com> (github: viirya)
Merge pull request #4818 from viirya/fix_working_dir_not_dir

fix the problem when setting existing file as working dir