fix the problem when setting existing file as working dir


This PR is proposed to check if the working dir is a directory. If it is an existing file, an error is returned.
For example, when given -w=/bin/cat, original codes would cause docker to halt.